Tsallaka zuwa abun ciki
Justice Tech School

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
done

Result

apple: starts with a
banana: tropical
kiwi: tropical

Exercise

Default pattern.

) echo other ;;

Quiz Test

What ends a case branch?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.