March 2002
Beginner
504 pages
10h 47m
English
The case statement is the second form of flow control available in the shell. Its syntax is as follows:
case word in pattern1) list1 ;; pattern2) list2 ;; ... patternN) listN ;; esac
Here the string word is compared to each of the patterns from pattern1 to pattern. When a matching pattern is found, the list following the matching pattern is then executed.
When a list finishes executing, the special command ;; indicates that flow should jump to the end of the case statement. The ;; is similar to the break command in the C programming language. If no matches are found, the case statement does not perform any actions. The minimum number of patterns is one. There is no limit on the maximum number of patterns.
Some programmers ...
Read now
Unlock full access