O'Reilly logo

Korn Shell: Unix and Linux Programming Manual, Third Edition, The by Anatole Olczak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Control Commands

The Korn shell provides a number of control-flow commands typically found in high-level programming languages. The following sections cover these special commands.

The case Command

The case command provides multiple-branch capability. It is used to compare a single value against a number of other values. Commands associated with that value are executed when a match is made. The syntax for the case command is:

						case
						value
						in
						pattern1)
						command
						command;; 
       pattern2)
						command
						command;; 
       . . . 
       patternn)
						command
						command;; 
esac
					

where value is compared to pattern1, pattern2, ... patternn. When a match is found, the commands associated with that pattern up to the double semi-colons are executed.

The following Korn shell script demonstrates ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required