Take the 2-minute tour ×  When pre/post incrementing a variable,
in POSIX Shell, what is the difference between these two
examples. They seem like they would have the same consequences,
but would they be used differently? When would you prefer one
over the other?   : $((X=X+1)) share|improve this question add
comment  1 Answer  up vote 6 down vote accepted  In your first
example, $((X+1)) evaluates the expression X + 1 and expands to
the result, which is then asigned to the variable.  In the
second example, $((X=X+1)) increments X by one ($((X++)) is also
valid and shorter, but not necessarily supported by the shell),
then expands to the new value of $X, which is the first argument
to the null command, :. The null command ignores its arguments,
and the result is discarded (with side effects).  I would
personally prefer the first form because of three (relatively
subjective) reasons:    • The null command is obscure and
misunderstood, as indicated by its often being the subject of
confused questions here.   •