2194 shaares
908 private links
908 private links
A Shell script usually needs to test if a command succeeds or a condition is met. In Bash, this test can be done with a Bash if statement. As with any other programming language, Bash comes with conditional expressions that allow you to test for conditions and alter the control flow if the condition is satisfied or not.
This post covers the bash if statement and the related clauses then, else if (elif), and else.