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.
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 executed.
The syntax of
else is as follows:
if [ conditional_expression ] then statements else statements fi