Seq in Linux
seq: used to generate all integers from a certain number to another
seq parameters
parameter | Features |
---|---|
-f, --format=FORMAT | use printf style floating-point FORMAT (default: %g) |
-s, --separator=STRING | use STRING to separate numbers (default: \n) |
-w, --equal-width | equalize width by padding with leading zeroes |
Example 1:
seq 1 10
The result is 1 2 3 4 5 6 7 8 9 10
Example 2:
#!/bin/bash
for i in `seq 1 10`;
do
echo $i;
done
Or use
for i in $(seq 1 10)
Example 3:
seq -f"%3g" 9 11
9
10
11
【Note: The number of digits specified after% is "%g", "%3g" by default, so the lack of digits is a space】