Ad space (banner)
🖥️Linux Lessons
Lesson 48 / 61

Generating a Sequence with seq

seq is for when "I want to generate the sequence 1 through 10." seq stands for sequence, and it outputs a consecutive range of numbers, one per line.

Use it in the form seq start end. Specify an increment with seq start increment end, and you can generate sequences that step by 2, and so on.

Running seq 1 5 outputs the numbers 1 through 5, one per line, across 5 lines total.

A common early mistake is not distinguishing between a shell environment whose for-loop supports range syntax directly, versus one that needs seq, and ending up with an environment-dependent script.

In real work, this is used inside shell scripts to generate a loop count, or to batch-generate a set of sequentially-numbered filenames.

Linux
Try it (type this into the pseudo terminal)
seq 1 5

🧑‍💻 You can type this command into the Linux pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)