On this page
reference
1 min read
seq
seq prints a sequence of numbers, one per line.
seq [options] last
seq [options] first last
seq [options] first increment last
$ seq 3
1
2
3
$ seq 2 2 10
2
4
6
8
10
The three forms control where the sequence starts and how it steps:
seq last— count from 1 up tolast.seq first last— count fromfirstup tolast.seq first increment last— count fromfirsttolast, stepping byincrement.
The increment may be negative, to count down, and the numbers may be fractional. seq is most often used to drive a loop a fixed number of times.
Options
| Option | Effect |
|---|---|
-s, --separator=STRING |
Separate the numbers with STRING instead of a newline. |
-t, --terminator=STRING |
End the output with STRING instead of a newline. |
-w, --equal-width |
Pad the numbers with leading zeros so they all have the same width. |
-f, --format=FORMAT |
Format each number with a printf-style floating-point FORMAT. |
$ seq -s , 1 5
1,2,3,4,5
$ seq -w 8 10
08
09
10
-f takes a single floating-point conversion — see printf for the format syntax — and cannot be combined with -w.
Exit status
| Code | Meaning |
|---|---|
0 |
The sequence was printed. |
1 |
An argument was not a valid number, the increment was zero, or no argument was given. |
See also
Peios Learn
Built with Trail