Tsallaka zuwa abun ciki
Justice Tech School

Practice: Simple Menu Script

Combine functions, case and arguments.

Example
run() {
  case $1 in
    start) echo "starting" ;;
    stop) echo "stopping" ;;
    *) echo "usage: $0 start|stop" ;;
  esac
}
run start
run stop
run x

Result

starting
stopping
usage: /tmp/tmphhb2n6lu.sh start|stop

Exercise

Print status.

case $1 in ) echo go ;; esac

Quiz Test

Where do usage messages go?

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