2122 shaares
901 private links
901 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.