seq
Linux · Text · reference only
What it does
Generates a sequence of numbers, with configurable start, step and end. It is very useful in loops and scripts.
Syntax
seq [opciones] final seq [opciones] inicio final seq [opciones] inicio paso final
Options and parameters
-s separadorUses that string to separate the numbers instead of a newline.
-wPads with leading zeros so all numbers have the same width.
-f formatoFormats each number printf-style, such as %03g.
--helpShows help and exits.
--versionShows the version and exits.
Usage examples
seq 5Prints 1 to 5, one per line.
seq 1 2 9Prints 1, 3, 5, 7 and 9: counting by 2.
seq -s, 1 5Prints 1,2,3,4,5 on a single comma-separated line.
seq -w 8 10Prints 08, 09 and 10, with zeros to equalize the width.
Notes and common mistakes
- With a negative step it counts down: seq 10 -3 1 prints 10, 7, 4 and 1.