-
Case statment is used for simplifying mulitple condition check with multiple different choices.
echo "1. Shutdown" echo "2. Restart" echo "3. Exit Menu" read –p "Enter your choice: " choice case $choice in 1) shutdown now ;; 2) shutdown –r now ;; 3) break ;; *) continue ;; esac -
Case statement can also be written along with the
whileloop as shownwhile true do echo "1. Shutdown" echo "2. Restart" echo "3. Exit Menu" read –p "Enter your choice: " choice case $choice in 1) shutdown now ;; 2) shutdown –r now ;; 3) break ;; *) continue ;; esac done