Hi,
is there an equivalent of switch in bash?
			
			
									
						
										
						switch in bash
- 
				chris
 - Site Admin
 - Posts: 216
 - Joined: Mon Jul 21, 2008 9:52 am
 
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';
;;
esacanything else will result in default.
I think it is a string compare, so you can use anything.