Answers for "shell script switch case example"

1

case statement example shell scripting

#!/bin/sh

echo "Please talk to me ..."
while :
do
  read INPUT_STRING
  case $INPUT_STRING in
	hello)
		echo "Hello yourself!"
		;;
	bye)
		echo "See you again!"
		break
		;;
	*)
		echo "Sorry, I don't understand"
		;;
  esac
done
echo 
echo "That's all folks!"
Posted by: Guest on May-08-2021
1

bash switch case

case $1 in
start)
    #Start logic
    ;;
stop)
    # Stop logic
    ;;
*)
	# Default logic
    echo $"Usage: $0 {start|stop}"
    exit 1
    ;;
esac
Posted by: Guest on September-14-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language