Sometimes you need to quickly generate a number of files or directories with different, but not random, numbers and names. That's when seq command is perfect!
Count Sequences using Seq
Simplest is to specify the start and end values for your sequence:
[email protected]:~ $ seq 1 5
So in this example we start with the first parameter (1) and count sequence until the value becomes the last parameter (5).
Specifying the increment step with seq
Sometimes you want to increment by more than just 1, this is how you can use step of 3, for instance:
[email protected]:~ $ seq 1 3 13 1 4 7 10 13
IMPORTANT: Strange thing to note is that when you use 3 parameters for the seq command, 2nd parameter stops acting as the last number in sequence and becomes an increment. So in our example we start with 1, increment by second parameter (3) and count until we reach 3rd parameter (13).
Counting Down with seq
It's possible to specify a negative step for your sequence – instead of counting from 1 to 10, for example, you can be counting down from 10 to 1.
Here's how we use -1 to count down from 10 to 0:
So t [email protected]:~ $ seq 10 -1 0 10 9 8 7 6 5 4 3 2 1 0