O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

seq — stdin  stdout  - file  -- opt  --help  --version

Synopsis

seq [options] specification

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 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 2 5
2
3
4
5
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

You can also go backward with a negative increment:

$ seq 5 -1 2
5
4
3
2

Useful options

-w

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

$ seq -w 8 10
08
09
10

-f format

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required