for ((i=1; i<=10; ++i)); do echo $i; done
This is equivalent to seq 1 10
, but portable. seq
is not a standard tool and as such it may not exist in all systems, in fact it is discouraged as of today. Other variations to emulate various uses with seq
:
# seq 1 2 10
for ((i=1; i<=10; i+=2)); do echo $i; done
# seq -w 5 10
for ((i=5; i<=10; ++i)); do printf '%02d\n' $i; done
echo {01..10}
perl -e 'print "$_\n" for (1..10)'
for i in {1..10}; do echo "$i"; done