Iterating through a range of ints in ksh?

razlebe picture razlebe · Oct 19, 2009 · Viewed 55.1k times · Source

How can I iterate through a simple range of ints using a for loop in ksh?

For example, my script currently does this...

for i in 1 2 3 4 5 6 7
do
   #stuff
done

...but I'd like to extend the range way above 7. Is there a better syntax?

Answer

martin clayton picture martin clayton · Oct 19, 2009

Curly brackets?

for i in {1..7}
do
   #stuff
done