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 last.
first also defaults to ‘1’. So
seq 1 prints
seq 0 and
seq 10 5 produce no output.
Floating-point numbers may be specified. See Floating point.
The program accepts the following options. Also see Common options. Options must precede operands.
The default format is derived from first, step, and
last. If these all use a fixed point decimal representation,
the default format is ‘%.pf’, where p is the minimum
precision that can represent the output numbers exactly. Otherwise,
the default format is ‘%g’.
You can get finer-grained control over output with -f:
$ seq -f '(%9.2E)' -9e5 1.1e6 1.3e6 (-9.00E+05) ( 2.00E+05) ( 1.30E+06)
If you want hexadecimal integer output, you can use printf to perform the conversion:
$ printf '%x\n' $(seq 1048575 1024 1050623) fffff 1003ff 1007ff
For very long lists of numbers, use xargs to avoid system limitations on the length of an argument list:
$ seq 1000000 | xargs printf '%x\n' | tail -n 3 f423e f423f f4240
To generate octal output, use the printf
%o format instead
On most systems, seq can produce whole-number output for values up to at least 2^53. Larger integers are approximated. The details differ depending on your floating-point implementation. See Floating point. A common case is that seq works with integers through 2^64, and larger integers may not be numerically correct:
$ seq 50000000000000000000 2 50000000000000000004 50000000000000000000 50000000000000000000 50000000000000000004
However, note that when limited to non-negative whole numbers, an increment of 1 and no format-specifying option, seq can print arbitrarily large numbers.
Be careful when using seq with outlandish values: otherwise you may see surprising results, as seq uses floating point internally. For example, on the x86 platform, where the internal representation uses a 64-bit fraction, the command:
seq 1 0.0000000000000000001 1.0000000000000000009
outputs 1.0000000000000000007 twice and skips 1.0000000000000000008.
An exit status of zero indicates success, and a nonzero value indicates failure.