Back to the command reference

seq

ShellFundamentals In simulator In real Linux

Print a sequence of numbers

Name: seq = sequence

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

seq prints a sequence of numbers with optional start and step; -w pads them to equal width. Scripts use it with for loops or xargs; in bash {1..10} works too.

Syntax

seq [FIRST [INCREMENT]] LAST

Common options

FIRST INCREMENT LASTStart, step and end
-w / --equal-widthPad with zeros to equal width (01 02 … 10)
-s / --separator STRINGSeparate the numbers with STRING (a newline by default), e.g. seq -s, 5
-f / --format FORMATUse a printf format, e.g. -f "file%03g"

Examples

  • $ seq 5

    Print 1 to 5

    Explain
  • $ seq 0 10 50

    0 to 50 in steps of 10

    Explain
  • $ seq 3 | wc -l

    Combine with other commands

    Explain

Related