Tsallaka zuwa abun ciki
Justice Tech School

Case Statements

case matches a value against patterns, each ending with ;;. Use | for alternatives, * as the default and esac to end.

Example
for x in start stop other; do
  case $x in
    start|go) echo "starting" ;;
    stop) echo "stopping" ;;
    *) echo "unknown: $x" ;;
  esac
done

Result

starting
stopping
unknown: other

Exercise

End a case block.

case $x in a) ;; 

Quiz Test

What ends a case block?

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