COHERENT manpages
This page displays the COHERENT manpage for case [Execute commands conditionally according to pattern].
List of available manpages
Index
case -- Command
Execute commands conditionally according to pattern
case token in [pattern [|pattern] ...) sequence ;;] ... esac
case is a construct that used by the shell. It tells the shell to execute
commands conditionally, according to a pattern. It tests the given token
successively against each pattern, in the order given. It then executes
the commands in the sequence corresponding to the first matching pattern.
Optional `|' clauses specify additional patterns corresponding to a single
sequence. If no pattern matches the token, the case construct executes no
commands.
Each pattern can include text characters (which match themselves), special
characters `?' (which matches any character except newline) and `*' (which
matches any sequence of non-newline characters), and character classes
enclosed in brackets `[ ]'; ranges of characters within a class may be
separated by `-'. In particular, the last pattern in a case construct is
often `*', which will match any token.
The shell executes case directly.
Example
The following example prints a string in response to a command-line option:
case $1 in
FOO) echo "This is option FOO";;
BAR) echo "This is option BAR";;
BAZ) echo "This is option BAZ";;
*) echo "An asterisk marks the default option";;
esac
See Also
commands,
ksh,
sh