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 separador

    Uses that string to separate the numbers instead of a newline.

  • -w

    Pads with leading zeros so all numbers have the same width.

  • -f formato

    Formats each number printf-style, such as %03g.

  • --help

    Shows help and exits.

  • --version

    Shows the version and exits.

Usage examples

  • seq 5

    Prints 1 to 5, one per line.

  • seq 1 2 9

    Prints 1, 3, 5, 7 and 9: counting by 2.

  • seq -s, 1 5

    Prints 1,2,3,4,5 on a single comma-separated line.

  • seq -w 8 10

    Prints 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.

Related commands