Skip to main content
6 of 12
added 3 characters in body

Interestingly enough, noone actually ever mentioned the truly fastest way to do loops in bash:

x=4000000

declare -i i=0
while ((i++ < x)); do
  :
done

or for other than +1 iterations (slightly slower) use:

x=4000000

i=-1
while (((i += 1) < x)); do
  :
done

Which is about 17% faster than the C-like for loop.