On previous post explained simple IF statement and this post describe about CASE...ESAC statement,
Each case is an expression corresponding a pattern, The commands is the commands1 for case-1 is executed. The symbol ")" is used for seperating multiple commands.
Finally the case statement is closed with the esac.
Case Statement Syntax
case EXPRESSION in
CASE-1) Commands1
;;
CASE-2) Commands2
;;
...
CASE-N) Commands3
;;
esac
Simple Case Statement Script
#!/bin/bash
echo "ISO Code's are:"
echo "IN = India"
echo "US = USA"
echo "UKR= Ukraine"
echo -n "Enter Your Country Name : "
#read COUNTRY
case "$COUNTRY" in
"IN") echo " You have Selected $COUNTRY "
;;
"US") echo " You have Selected $COUNTRY "
;;
"UKR") echo " You have Selected $COUNTRY "
;;
esac
Comments (0)