Conditional constructs – if else
We use the
if command to check the pattern or command status and accordingly we can make certain decisions to execute scripts or commands.
The syntax of the
if conditional is as follows:
if command then command command fi
From the preceding syntax, we can clearly understand the working of the
if conditional construct. Initially,
if will execute the command. If the result of command execution is true or 0, then all the commands that are enclosed between
fi will be executed. If the status of command execution after
if is false or nonzero, then all the commands after
then will be ignored and the control of execution will directly go to
Let's learn another variation of
if command then ...