case Statements
case matches a value against patterns. ;; ends each branch.
Example
for x in apple banana kiwi; do
case $x in
a*) echo "$x: starts with a" ;;
banana|kiwi) echo "$x: tropical" ;;
*) echo "$x: other" ;;
esac
doneResult
apple: starts with a banana: tropical kiwi: tropical
Exercise
Default pattern.
) echo other ;;Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.