Friday, July 9, 2010

GNU Coreutils "seq"

the manual page.

Why do I keep forgetting the name of this wonderful little helper?


seq prints a sequence of numbers to standard output. Synopses:
     seq [option]... last
     seq [option]... first last
     seq [option]... first increment last
seq prints the numbers from first to last by increment. By default, each number is printed on a separate line. When increment is not specified, it defaults to ‘1’, even when first is larger than lastfirst also defaults to ‘1’. So seq 1 prints ‘1’, but seq 0 and seq 10 5 produce no output. Floating-point numbers may be specified (using a period before any fractional digits).

1 comment:

Anonymous said...

So to get the count from 10 to 1, set increment to -1:

seq 10 -1 1

Modern shells also have the simple way (increment=1) built in:

echo {1..10}