May 2017
Beginner
552 pages
28h 47m
English
Here are some methods used for comparisons and performing tests:
if condition;
then
commands;
fi
if condition;
then
commands;
else if condition; then
commands;
else
commands;
fi
Nesting is possible with if and else. The if conditions can be lengthy; to make them shorter we can use logical operators:
[ condition ] && action; # action executes if the condition is true
[ condition ] || action; # action executes if the condition is false
&& is the logical AND operation and || is the logical OR operation. This is a very helpful trick while writing Bash scripts. Performing mathematical comparisons: usually, conditions are enclosed in square brackets []. Note that there is a space ...