Difference between revisions of "Bash if elif else fi"

From thelinuxwiki
Jump to: navigation, search
Line 24: Line 24:
 
OR example
 
OR example
 
  <nowiki>
 
  <nowiki>
  if [[ "$VARIABLE" == "something" || "$VARIABLE" == "else" ]]; then
+
  if [[ "$VARIABLE" == "something" || "$VARIABLE" == "else" ]]; then</nowiki>
</nowiki>
+
    some_command
  some_command
+
 
  fi
 
  fi

Revision as of 16:24, 17 March 2014

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" == "something" || "$VARIABLE" == "else" ]]; then
   some_command
fi