Name

seq [options] specification — coreutils

Synopsis

/usr/bin stdin stdout - file -- opt --help --version

The seq command prints a sequence of integers or real numbers, suitable for piping to other programs. There are three kinds of specification arguments:

A single number: an upper limit

seq begins at 1 and counts up or down to the number.

$ seq 3
1
2
3
Two numbers: lower and upper limit

seq begins at the first number and counts as far as it can without passing the second number.

$ seq 5 2
5
4
3
2
Three numbers: lower limit, increment, and upper limit

seq begins at the first number, increments by the second number, and stops at (or before) the third number.

$ seq 1 .3 2
1
1.3
1.6
1.9

Useful options

-w

Print leading zeroes, as necessary, to give all lines the same width:

$ seq -w 8 10
08
09
10

-f format_string

Format the output lines with a printf-like format string, which must include either %g (the default), %e, or %f:

$ seq -f '**%g**' 3
**1**
**2**
**3**

-s string

Use the given string as a separator between the numbers. By default, a newline is printed (i.e., one number per line):

$ seq -s ':' 10
1:2:3:4:5:6:7:8:9:10

Get Linux Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.