From charlesreid1

The seq command can be used for creating numerical sequences of numbers.

Basic Use of Seq

If you want a list of numbers from 1 to 10:

$ seq 1 10
1
2
3
4
5
6
7
8
9
10

or, if you want a backwards list:

$ seq 10 1
10
9
8
7
6
5
4
3
2
1

Decimal Numbers

Seq can handle decimal increments as well:

$ seq 0 0.5 5
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5

Custom Increment

If you want a sequence of numbers from A to B with a particular increment i, feed three arguments to seq: seq A i B

$ seq 0 5 50
0
5
10
15
20
25
30
35
40
45
50

You can also give negative increments,

$ seq 50 -5 0
50
45
40
35
30
25
20
15
10
5
0

Custom Separator

Creating a comma-separated list of numbers is often more useful/interesting than each number on a separate line:

$ seq -s, 0 2 10
0,2,4,6,8,10,

You can also use escape characters, like a double-newline:

$ seq -s'\n\n' 0 2 10
0

2

4

6

8

10

Custom String Terminator

$ seq -t'\n...' 0 2 10
0
2
4
6
8
10

...

Zero-Padding

Sometimes it's useful to have a fixed-width number, with zero-padding. That's why seq offers the -w (for width) option:

$ seq -w 0 2 10
00
02
04
06
08
10

Complex String Formatting

You can use the -f flag to format your string using printf functionality.

To print a 4-digit integer, with zero padding, you'll use the %04g printf sequence:

$ seq -f'%04g' 0 2 10
0000
0002
0004
0006
0008
0010

To print a 4-digit integer with spaces for padding, you can use the %4g printf sequence:

$ seq -f'%4g' 0 2 10
   0
   2
   4
   6
   8
  10

To print the sequence of numbers with a prefix, you can add a prefix to the printf sequence, e.g.:

$ seq -f'_%04g' 0 2 10
_0000
_0002
_0004
_0006
_0008
_0010

Combining Seq with Other Unix Utilities