#!/bin/sh -u # # $0 # # A script that reads a line and chooses cases based on the input. # # WARNING: Many of the comments in this file are "Instructor-Type" # comments and are *not* appropriate for real scripts. Do not put # "Instructor-Type" comments into the scripts that you submit for marking. # I put them in my example files because I am teaching you how to # write scripts; do not submit my teaching comments back to me again. # Read the week7.txt notes for more details on good comment style. # # -IAN! idallen@ncf.ca June 2001 # All scripts must start with lines similar to these two: # export PATH=/bin:/usr/bin umask 022 # Prompt (on stderr) and read one line of input. # echo 1>&2 "Input?" read input # Choose cases based on pattern matching the input. # case "$input" in hello) echo "hello: You typed '$input'." ;; goodbye) echo "goodbye: You typed '$input'." ;; *hello) echo "*hello: You typed '$input'." ;; *bye*) echo "*bye*: You typed '$input'." ;; [yn]) echo "[yn]: You typed '$input'." ;; a*|*b|??) echo "a*|*b|??: You typed '$input'." ;; *) echo "*: (DEFAULT) You typed '$input'." echo "This is the default case." echo "The * pattern always matches." ;; esac exit 0