else to run conditional statements depending upon whether the evaluation is
false. It is useful if we want to perform certain tasks only if a certain condition is
The test condition to if can be given using a test condition or [condition]. We have already learned multiple use cases and examples of testing an expression in the previous section, Testing expressions with a test.
The syntax of the
if condition is as follows:
if [ conditional_expression ] then statements fi
true—that is, the exit status is
0—then the statements inside it get executed. If not, then it will be just be ignored and the next line after
fi will be ...