I want to write a loop in Bourne shell which iterates a specific set of numbers. Normally I would use seq
:
for i in `seq 1 10 15 20`
#do stuff
loop
But seemingly on this Solaris box seq
does not exist. Can anyone help by providing another solution to iterating a list of numbers?
try
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
OR use tool like nawk
OR even the while loop
You can emulate
seq
withdc
:For instance:
is rewritten as:
Another variation using
bc
:For the Bourne shell, you'll probably have to use backticks, but avoid them if you can:
Result:
$ man seq
I find that this works, albeit ugly as sin: