case

NAME

case - conditionally execute one of a number of statement lists

SYNOPSIS

case word in [[(] pattern [| pattern]... ) list ;; ] ... esac

DESCRIPTION

This command is a Korn-shell built-in command.

The case statement attempts to match word against the specified patterns; the list associated with the first successfully matched pattern is executed. Patterns used in case statements are the same as those used for file-name patterns, except that the restrictions regarding . and / are dropped. Note that any unquoted space before and after a pattern is stripped; any space with a pattern must be quoted. Both the word and the patterns are subject to parameter, command, and arithmetic substitution, as well as tilde substitution.

For historical reasons, open and close braces ({}) can be used instead of in and esac (for example, case $foo { *) echo bar; }). The exit status of a case statement is that of the executed list; if no list is executed, the exit status is zero.