Browsing around...
News  News Links  Links Blog  Blog Italiano  Español 
07 - Case structure in the bash


The case..esac construct allows to execute an operation according to the value assumed by a variable. The structure is:

case $control_variable in
 0) code0
 1) code1
 2) code2

If the variable assumes the value 0, the codice0 is executed; if the variable assumes the value 1, the code1 is executed, etc. Here is an example:

case $x in
  0) echo "Value of x: 0"
  5) echo "Value of x: 5"
  9) echo "Value of x: 9"



No comment present!

Write a comment

You can write here a comment to the article you've just read. Smiles, links and images are not allowed. The maximum comment length is 4000 characters. Please be polite, all the offensive messages will be deleted.

Your comment (lascia bianco!):
Uses (max 25 characters, required)
Web site (max 255 characters, optional)
e-Mail (max 255 characters, optional, will not be published) Your opinion (lascia bianco!):
Comment (max 4000 characters, required):

Valid HTML 4.01 Transitional
E-Mail - 20.18 ms

Valid HTML 4.01 Transitional