When you are architecting a massive bash script that requires iterating through a strict numerical matrix (e.g., creating 500 numbered directories or pinging a specific range of IP addresses), manually typing the array is mathematically absurd. To force the Linux kernel to algorithmically generate and output a perfect, highly structured sequence of integers or floating-point numbers, you must deploy the seq command.
Executing the Sequence Generator
The seq (Sequence) command is a dedicated mathematical engine. It ingests one, two, or three numerical arguments and algorithmically loops from a start vector to an end vector, outputting each discrete step to standard output.
Executing a Basic Numerical Matrix
If you only provide a single argument, the engine mathematically assumes the sequence begins at exactly 1 and increments by exactly 1.
seq 5
The exact millisecond you press Enter, the engine outputs:
1
2
3
4
5
Executing Complex Geometric Loops
To execute a highly complex matrix, you must inject three absolute arguments: the Start integer, the Increment (step) integer, and the End integer. seq [START] [INCREMENT] [END].
Imagine you need to generate a list of every multiple of 5, beginning at 15 and terminating at 35.
seq 15 5 35
The engine violently executes the loop, jumping by exactly 5 units on every iteration, outputting:
15
20
25
30
35
Injecting Sequences into Bash Loops
The true power of seq is realized when nested within a for loop to drive script execution. If you need to create five directories named server_1 through server_5, you can pipe the seq output directly into the loop structure using command substitution (backticks or $()):
for i in $(seq 1 5); do mkdir server_$i; done
The bash interpreter will execute the seq command first, generate the array, and instantly pass the integers to the mkdir command, rapidly creating the physical directory structure.