22
3
Im learning shell scripting from an outdated textbook, and it seems to me like it'd be really usefull to have a program that just returns a string of numbers delimited by spaces something like
$ range 10 20
10 11 12 13 14 15 16 17 18 19 20
Then, if youre doing a shell script you can have
for i in `range 10 20`; do some stuff with numbers in that range;done
does such a thing exist, or do I need to write it myself?
when you say "unix", do you really mean Linux? Or are you really interested in portability to other systems (Solaris, BSD, ...)? – glenn jackman – 2013-05-28T10:51:55.663
2s/range/seq - replace
range
withseq
in your example. default separator is newline, to have spaces:seq -s " " 10 20
– n611x007 – 2013-05-28T13:27:58.673@naxa Whether it's spaces or newlines does not matter in the
for
loop—or even any general command that splits arguments—unless you've set the IFS differently. – slhck – 2013-05-28T13:46:42.0271This question should define what "standard unix program" means to OP. – David Rivers – 2013-05-28T14:46:57.923
I say unix because im learning linux from the book "The Unix Programming Environment" by pike (I know its dated, but I like it). – MYV – 2013-05-29T18:48:04.273
1As @DavidRivers already commented, you should state in the title and the question your focus is on Linux distributions. The answer you accepted suggests a tool which is NOT a standard Unix program. Several Unix are lacking
seq
as it is not specified by POSIX. – jlliagre – 2013-08-22T15:32:26.467