Bourne Shell For i in (seq) Bourne Shell For i in (seq) shell shell

Bourne Shell For i in (seq)


try

for i in 1 10 15 20do   echo "do something with $i"done

else if you have recent Solaris, there is bash 3 at least. for example this give range from 1 to 10 and 15 to 20

for i in {1..10} {15..20}do  echo "$i"done

OR use tool like nawk

for i in `nawk 'BEGIN{ for(i=1;i<=10;i++) print i}'`do  echo $idone

OR even the while loop

while [ "$s" -lt 10 ]; do s=`echo $s+1|bc`; echo $s; done


You can emulate seq with dc:

For instance:

seq 0 5 120

is rewritten as:

dc -e '0 5 120  1+stsisb[pli+dlt>a]salblax'


Another variation using bc:

for i in $(echo "for (i=0;i<=3;i++) i"|bc); do echo "$i"; done

For the Bourne shell, you'll probably have to use backticks, but avoid them if you can:

for i in `echo "for (i=0;i<=3;i++) i"|bc`; do echo "$i"; done