Bash if elif else fi

From thelinuxwiki
Revision as of 16:23, 17 March 2014 by Nighthawk (Talk | contribs)

Jump to: navigation, search

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

OR example

if | "$VARIABLE" == "else" ; then
  some_command
fi