Tuesday, February 5, 2008

do something a given number of times (bash)

Like this (do from 1 to 34) ./intensity2cycle ./s_1_0001_sig2.txt.filtered ./cycleNUMBER NUBMER

for i in $(seq 1 34); do ./intensity2cycle ./s_1_0001_sig2.txt.filtered ./cycle$i $i; done


Anonymous said...

Alternatively use the built-in arithmetic bash looping:
for ((i=1; i<=34; i++)); do ./intensity2cycle ./s_1_0001_sig2.txt.filtered ./cycle$i $i; done

new said...

cheers, that looks like a better way of doing it.

Anonymous said...

better yet, brace expansion ...

for i in {1..34}
./cycle$i $i

This gives you better performance than the previous mentions; although, at 34 iterations, you won't see much of an improvement.