Bash case Statement
A case statement compares one value against several patterns and runs the commands of the first match.
Each block ends with ;;, *) matches anything else, and the statement ends with esac.
Choose by value
Save this as fruit.sh:
#!/bin/bash
fruit="apple"
case $fruit in
apple)
echo "Apples are red or green"
;;
banana|lemon)
echo "This fruit is yellow"
;;
*)
echo "Unknown fruit"
;;
esac
Run it:
./fruit.sh
Apples are red or green