What it does
seq LAST prints 1 to LAST; seq FIRST LAST and seq FIRST STEP LAST set the start and step. In bash, {1..10} does the same without a program, but seq also works with variables and decimals.
How to write it
seq [OPTION]... LAST
seq [OPTION]... FIRST LAST
seq [OPTION]... FIRST INCREMENT LASTOptions 5
Most used
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
11 to 5
seq 5One number per line.
2Loop over numbers
for i in $(seq 1 3); do echo "round $i"; doneAlso: for i in {1..3}.
3With a variable end
N=4; for i in $(seq 1 $N); do echo $i; done{1..$N} does not work in bash.
4Steps
seq 0 10 50 0 10 20 30 40 50Start, step, end.
5Count down
seq 5 -1 1Negative step.
6Equal width
seq -w 8 11 08 09 10 11For file names.
7One line with commas
seq -s, 1 5 1,2,3,4,5Lists for other commands.
8Ping a range of hosts
Quick scan of your own lab network.
9Create test files
for i in $(seq -w 1 20); do touch file$i.txt; donefile01.txt … file20.txt.
10Decimal steps
seq -f "%.1f" 0 0.5 20.0 0.5 1.0 1.5 2.0.
Nothing matches this filter.
Exit codes
0 :: Done. 1 :: Error.