- i=$(($i + 1))
+ : $(( i += 1 ))If you don't know
: builtin yet, read first entry of "SHELL BUILTIN COMMANDS." I have been using it quite often with infinite while loop, e.g.while :; do
do_something
doneI never thought of putting something behind it, and that diff is quite genius in my opinion. However I will just write
(( i++ ))I don't see there is a reason for using Arithmetic Expansion, Evaluation is enough and clear. Expansion will returns the expanded string, which cause command execution if you don't prefix with
:, and you will get "command not found" error.There is a good use of
:, putting it after last command of a function or last command of a script, if they have chances to return non-zero and you do not care if that command runs into problem. This way it will clear out the returned value.