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?
Curly brackets?
for i in {1..7}
do
#stuff
done
While loop?
while [[ $i -lt 1000 ]] ; do
# stuff
(( i += 1 ))
done
on OpenBSD, use jot:
for i in `jot 10`; do echo $i ; done;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With