To give you the best experience, this site uses cookies. Continuing to use 9bis.net means you agree to our use of cookies.
 

 

case ... in : ... ;; esac ( en )

Last modification : 2013/01/26 19:16

If there are many else expression into a if ... then ... else ... fi, it is possible to write a case block such as a switch command in a C program.
Here it is the syntax:
case variable in
      value1 : command 1 ;;
      value2 : command 2 ;;
      ...
esac

Example:
msh> set A=1
msh> case $A in
    1>    -1: print Negative ;;
    1>     0: print Null ;;
    1>     1: print Positive ;;
    1> esac
Positive