C-style loops in bash
Just found out it's possible to use C-style loops in bash, for example:
for ((i=0; i<10; i++)); do
echo $i;
done
General form:
for (( expr1 ; expr2 ; expr3 )) ; do list ; done
It's extremely useful, and this feature works on bash>=2.04, so it has to work on most environments.
more info: http://www.softpanorama.org/Scripting/Shellorama/Control_structures/loops.shtml#C_style_for_loop
Written by Roman Rader
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#