spkandy
1
Hi Experts team,
i wish to use switch case in unix.
my req is
case $code in
1111)
echo "1111"
1112)
echo "1112"
*)
echo "default"
esac
see eventhough for particular case 1111 , it is always execute the default statement *), if i code like this.
How can handle numeric values in switch case in shell scripts.
Please explain
Thanks a lot 8)
This script seems to work for me:
#! /bin/sh
TEST=1111
case $TEST in
1111) echo "1111" ;;
1112) echo "1112" ;;
*) echo "None"
esac
returns '1111'
#! /bin/sh
TEST=1112
case $TEST in
1111) echo "1111" ;;
1112) echo "1112" ;;
*) echo "None"
esac
returns '1112'
write it in this way
case "$code" in
1111) echo "1111";;
1112) echo "1112";;
*) echo "default" ;;
esac