In Bash Scripts the following conditional expressions can be used.
if-else-fi
A single condition can be implemented as:
if [ <condition> ]
then
<do something>
else
<do something>
fiwhere the else part is optional but the spaces on both sides of the brackets [] are not.
if-elif-else-fi
Several conditions can be implemented with:
if [ <condition1> ]
then
<do something>
elif
then
<do something>
else
<do something>
fiSwitch Cases
Execute the statement corresponding to the pattern that <expressions> is equal to.
The syntax is:
case <expression> in
pattern1 ) statements1 ;;
pattern2 ) statements2 ;;
pattern3 ) statements3 ;;
esac