Home OS X
OS X Syntax

switch

Conditionally perform a command.

SYNTAX 
      switch (string)
       case str1:
	   ...
	   breaksw
       ...
       default:
	   ...
	   breaksw
       endsw   

Each case label is successively matched, against the specified string which is first command and filename expanded.

The file metacharacters `*', `?' and `[...]' may be used in the case labels, which are variable expanded.

If none of the labels match before a `default' label is found, then the execution begins after the default label.

Each case label and the default label must appear at the beginning of a line. The command breaksw causes execution to continue after the endsw. Otherwise control may fall through case labels and default labels as in C.

If no label matches and there is no default, execution continues after the endsw.

I saw a woman wearing a sweatshirt with "Guess" on it. I said, "Thyroid problem?" - Arnold Schwarzenegger

Related commands:

continue - Resume the next iteration of a while or foreach loop.
repeat - Execute a command multiple times
foreach - Loop, expand words, and execute commands
if - Conditionally perform a command
while - Execute commands

Equivalent BASH command:

case
- Conditionally perform a command



Back to the Top

Simon Sheppard
SS64.com