Answers for "case syntax shell"

7

bash case statement

case "$1" in
        start)
            start ;;
        stop)
            stop ;;
        restart)
            stop; start ;;
        *)
            echo $"Usage: $0 {start|stop|restart}"
            exit 1
esac
Posted by: Guest on May-24-2020
1

case syntax shell

case word in
   pattern1)
      # Statement(s) to be executed if pattern1 matches
      ;;
   pattern2)
      # Statement(s) to be executed if pattern2 matches
      ;;
   pattern3)
      # Statement(s) to be executed if pattern3 matches
      ;;
   *)
     # Default condition to be executed
     ;;
esac
Posted by: Guest on September-28-2021
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

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language