seqx
Print a sequence of numbers.
Mirrors GNU seq. Run it as seqx, or as gnux seqx.
Synopsis
seqx [OPTION]... [FIRST [INCREMENT]] LASTGNU reference
Description
seqx prints the numbers from FIRST to LAST, in steps of INCREMENT, one per line: 'seqx LAST', 'seqx FIRST LAST' or 'seqx FIRST INCREMENT LAST'. FIRST and INCREMENT default to 1, and INCREMENT may be negative to count down; nothing is printed when FIRST is already past LAST. Negative operands need no quoting or '--': as in GNU seq, an argument that starts with '-' followed by a digit or '.' is a number, and options must come before the operands. Without -f, numbers are printed with as many decimal places as FIRST and INCREMENT have, and the arithmetic is exact, so 'seqx 0.1 0.1 0.3' ends at 0.3. -f FORMAT prints each number through one printf floating-point directive (%e, %f, %g or %a, with flags, width and precision) and literal text around it; -s STRING separates the numbers with STRING instead of a newline; -w pads them with leading zeros to equal width, and cannot be combined with -f. LAST may be 'inf' to count forever, until the reader of the output goes away. Differences from GNU seq: -f values are formatted from double precision rather than long double, and an infinite FIRST or INCREMENT is refused as an invalid argument.
Permissions
Needs no filesystem permissions; it only writes to standard output.
Use cases
- Driving a loop over numbered items in a script, portably on every platform.
- Generating
testdata: a known number of lines to feed into another tool. - Producing zero-padded numbers with
-wfor file names that sort correctly. - Building comma- or space-separated lists of numbers with
-s. - Counting down with a negative increment.
- Generating evenly spaced decimal values, exactly, for tables or plots.
- Formatting numbers with a prefix, suffix or fixed precision through
-f. - Producing an endless numbered stream with 'inf' that a later stage cuts short.
Flags
-w, --equal-width equalize width by padding with leading zeroes
-f, --format FORMAT use printf style floating-point FORMAT
--help display this help and exit
-s, --separator STRING use STRING to separate numbers (default "\\n")
--version output version information and exitExamples
Print the numbers 1 to 5
seqx 5Print the numbers from 3 to 7
seqx 3 7Count in steps of 5
seqx 0 5 25Count down with a negative increment
seqx 10 -2 0Start from a negative number, with no quoting needed
seqx -3 3Step through decimals exactly
seqx 0 0.25 1Pad the numbers with zeros to equal width
seqx -w 8 12Separate the numbers with commas on one line
seqx -s , 1 10Format each number with a prefix and fixed precision
seqx -f 'item-%03.0f' 1 3Print percentages, with %% for a literal percent sign
seqx -f '%.0f%%' 0 25 100Number lines endlessly, stopping when the reader has enough
seqx 1 inf | headx -n 3Create ten numbered, zero-padded files
touchx $(seqx -f 'log-%02.0f.txt' 1 10)Sum the numbers 1 to 100 with another program
seqx -s + 1 100 | bcCount the numbers a sequence produces
seqx 0 3 100 | wcx -lGenerate numbered lines in the portable gnux shell
gnux shell -c 'seqx -f "line %g" 3 > lines.txt; catx lines.txt'Options
Each option has a page of its own, with its usage and examples.
- -w, --equal-width: Equalize width by padding with leading zeroes.
- -f, --format: Use
printfstyle floating-point FORMAT. - -s, --separator: Use STRING to separate numbers.
Exit status
| Status | Meaning |
|---|---|
| 0 | success: every operand was processed |
| 1 | failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake |
Help in the terminal
seqx --help # options, first examples, exit status
gnux help seqx # this page: the full manual
gnux help seqx --OPTION # one option in depth, with its examples