Difference between revisions of "Bash if elif else fi"

From thelinuxwiki
Jump to: navigation, search
(Pushed from Themanclub.)
 
Line 15: Line 15:
 
   else
 
   else
 
     statement5
 
     statement5
 +
  fi
 +
 +
== example ==
 +
  if [ "$opt" = "some string" ]; then
 +
    some_command
 
   fi
 
   fi

Revision as of 15:56, 11 April 2013

Bash If..elif..else..fi

 If [ conditional expression1 ]
 then
   statement1
   statement2
   .
 elif [ conditional expression2 ]
 then
   statement3
   statement4
   .
   .
   .
 else
   statement5
 fi

example

 if [ "$opt" = "some string" ]; then
   some_command
 fi