Flow control in a program is handled by comparison and test statements. Bash also comes with several options to perform tests that are compatible with the UNIX system-level features.
We can use
if else, and logical operators to perform tests and certain comparison operators to compare data items. There is also a command called
test available to perform tests. Let's see how to use those commands.
if condition; then commands; fi
else if and else:
if condition; then commands; elif condition; then commands else commands fi
Nesting is also possible with if and else.
if conditions can be lengthy. We can use logical operators to make them shorter as follows:
[ condition ] && action; # action ...