Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://comet.sai.msu.ru/UNIXhelp/scrpt/scrpt2.6.1.html
Дата изменения: Fri Jan 17 12:43:20 1997 Дата индексирования: Tue Oct 2 01:14:57 2012 Кодировка: Поисковые слова: п п п п п п п п |
case is a flow control construct that provides for multi-way branching based on patterns.
Program flow is controlled on the basis of the wordgiven. This word is compared with each pattern in order until a match is found, at which point the associated command(s) are executed.
case word in pattern1) command(s) ;; pattern2) command(s) ;; patternN) command(s) ;; esac
When all the commands are executed control is passed to the first statement after the esac. Each list of commands must end with a double semi-colon (;;).
A command can be associated with more than one pattern. Patterns can be separated from each other by a | symbol. For example:
case word in pattern1|pattern2) command ... ;;
Patterns are checked for a match in the order in which they appear. A command is always carried out after the first instance of a pattern.
The * character can be used to specify a default pattern as the * character is the shell wildcard character.