Generate number sequences with seq

Produce lists of numbers for loops, filenames, and quick test data.

LinuxscriptingLow risk
Run seq 1 10 to print 1 through 10, or seq 5 -1 1 to count down.

01Command

Command
$ seq 1 5 && seq -w 01 10 && for i in $(seq 1 3); do cp template.cfg cfg-$i.conf; done

02What it does

seq prints a range of numbers: one argument counts from 1 to N, two arguments are start and end, three add a step (including negative for countdowns). -w zero-pads so all numbers share the same width — handy for sort-stable filenames like img-01.jpg. Combined with $( ) it feeds for loops and xargs.

03Risk

RiskLow risk
!Warning: seq uses locale decimal points — in some locales seq 0.1 1 prints commas instead of dots, breaking arithmetic in scripts. For float math or complex loops, awk or bash brace ranges ({1..10}) are often cleaner (braces can't use variables, though).

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • seq(1) — Linux manual page
    man7.org · community · 2026-09-17
    Evidence: seq prints a sequence of numbers from first to last (optionally with increment); -w equalizes width with zero padding and -f formats each number.

Last verified: 2026-09-18 · Category: Developer