Unix Shell Script Case Statement

May 15, 2007 by Mark Marucot · Leave a Comment 

The case statement is similar to if .. else if .. else statement which performs specific statement/s if there are three or more conditions.
Syntax:

CODE:
  1. case word in
  2. value1) statements
  3. value2) statements
  4. *) statements
  5. esac

Example:

CODE:
  1. !#/bin/sh
  2. case $1
  3. in
  4. 1) echo ‘First Choice’;;
  5. 2) echo ‘Second Choice’;;
  6. *) echo ‘Other Choice’;;
  7. esac

Unix Shell Script Operators

May 15, 2007 by Mark Marucot · Leave a Comment 

The table below shows the list of operators used in conditional statements in Unix scripting.

Operator Description Example