casecase
value
in
pattern1 )
cmds1
;;
pattern2 )
cmds2
;;
. . . esac
Execute the first set of commands (cmds1
) if value
matches pattern1
, execute the second set of commands (cmds2
) if value
matches pattern2
, etc. Be sure the last command in each set ends with Korn Shell NotesExamplesCheck first command-line argument and take appropriate action: case $1 in # Match the first arg no|yes) response=1;; -[tT]) table=TRUE;; *) echo "unknown option"; exit 1;; esac Read user-supplied lines until user exits: while : # Null command; always true do echo "Type . to finish ==> \c" read line case "$line" in .) echo "Message done" break ;; *) echo "$line" >> $message ;; esac done |
|