Hi,
is there an equivalent of switch in bash?
switch in bash
Re: switch in bash
Yes, it look lik this:
in this case $VALUE can be 1 or 2,
anything else will result in default.
I think it is a string compare, so you can use anything.
Code: Select all
#Set the IP
case $VALUE in
1)
IP=192.168.1.160
NAME='a';
;;
2)
IP=192.168.1.161
NAME='B';
;;
*)
IP=192.168.1.1
NAME='Default';
;;
esac
anything else will result in default.
I think it is a string compare, so you can use anything.