SEQ(1) - General Commands Manual #
SEQ(1) - General Commands Manual
NAME #
seq - print sequences of numbers
SYNOPSIS #
seq [-w] [-f format] [-s string] [first [incr]] last
DESCRIPTION #
The seq utility prints a sequence of numbers, one per line by default, from first (default 1) to as near last as possible, in increments of incr (default 1). When first is larger than last, the default incr is -1.
All numbers are interpreted as floating point.
Normally, integer values are printed as decimal integers.
The seq utility accepts the following options:
-f format, –format format
Use a printf(3) style format to print each number. Only the A, a, E, e, F, f, G, g, and % conversion characters are valid, along with any optional flags and an optional numeric minimum field width or precision. The format can contain character escape sequences in backslash notation as defined in ANSI X3.159-1989 (“ANSI C89”). The default is %g.
-s string, –separator string
Use string to separate numbers. The string can contain character escape sequences in backslash notation as defined in ANSI X3.159-1989 (“ANSI C89”). The default is \n.
-w, –fixed-width
Equalize the widths of all numbers by padding with zeros as necessary. This option has no effect with the -f option. If any sequence numbers will be printed in exponential notation, the default conversion is changed to %e.
–help
Display the program usage and exit.
–version
Display the version number and exit.
EXIT STATUS #
The seq utility exits 0 on success, and >0 if an error occurs.
EXAMPLES #
Generate a sequence from 1 to 3 (inclusive) with a default increment of 1:
$ seq 1 3
1
2
3
Generate a sequence from 3 to 1 (inclusive) with a default increment of -1:
$ seq 3 1
3
2
1
Generate a sequence from 0 to 0.1 (inclusive) with an increment of 0.05 and padding with leading zeroes:
$ seq -w 0 .05 .1
0.00
0.05
0.10
Generate a sequence from 1 to 3 (inclusive) with a default increment of 1, and a custom separator string:
$ seq -s "," 1 3
1,2,3
Generate a sequence from 1 to 2 (inclusive) with an increment of 0.2 and print the results with two digits after the decimal point (using a printf(3) style format):
$ seq -f %.2f 1 0.2 2
1.00
1.20
1.40
1.60
1.80
2.00
SEE ALSO #
HISTORY #
A seq command appeared in Version 8 AT&T UNIX. This version of seq appeared in NetBSD 3.0 and was ported to OpenBSD 7.1.
BUGS #
The -w option does not handle the transition from pure floating point to exponent representation very well. The seq utility is not bug for bug compatible with other implementations.
OpenBSD 7.5 - September 21, 2023