Wednesday, March 17, 2010

bash for loop

Oooh, I just saw Bash for loop examples.

I definitely like:

for i in {1..100}
do
...
done


I don't usually need to step forward in increments greater than 1, but for that there's


for i in {1...100..2}
do
...
done


Of course there's also


for (( c=1; c<=100; c++ )) do ... done


which is what i've used in the past, but I always forget about the double parens.

No comments: