The switch construct can be used where nested conditions are required, but you don’t want to use complex if-else-elif chains.
#!/bin/bash echo -n "Enter a number: " read num case $num in 100) echo "Hundred!!" ;; 200) echo "Double Hundred!!" ;; *) echo "Neither 100 nor 200" ;; esac
NOTE: The conditions are written between the case and esac keywords.
The *) is used for matching all inputs other than 100 and 200.