case
Official Description
Executes the list associated with the first pattern that matches the word.
Syntax
case word in [[(] pattern [ | pattern] ...) list ;;] ... esac
Options
None
Oddities
The form of the patterns is the same as that used for filename generation.
Example
$ x=21 # Set value of x to 21 $ $ case $x in # Use case to check various values > 2 ) > print 2 ;; > 17 ) > print 17 ;; > 21 ) > print 21 ;; > * ) > print huh > esac 21 # Correctly finds the 21 $
Get Korn Shell Programming by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.