arithmetic expressions
Short form, it evaluates (integer-based) arithmetic expressions inside them and returns an exit code based on the result. This makes it possible to use it in conditional constructs like
for,
while, and
if. The
c-style-for loop is one common use of it. You should generally use them any time you want to test for a numerical condition, or apply an expression without having to deal with printed output (e.g. incrementing variables).
The related, posix-compliant structure is
$((..)). It also evaluates arithmetic, except that it only prints the resulting values to stdout, and doesn't produce an exit code.
Also see here for the other commonly-used test constructions. In general you should use
[[..]] for string and file conditions.
http://wiki.bash-hackers.org/syntax/...nal_expression
http://wiki.bash-hackers.org/commands/classictest