The Linux Newbie Guide  ⇒    Fundamentals     Advanced     Supplement   Command Index   ENG⇒中
All rights reserved, please indicate the source when citing
  

seq - Output Number Sequences



The seq command is a handy tool for generating number sequences in Linux. Its basic usage is as follows:
seq [OPTION]... FIRST INCREMENT LAST .

Here is a list of some commonly used options:

Examples:
$ seq 1 5 ←Outputs 1 to 5 (omitting INCREMENT, defaults to 1)
1
2
3
4
5
$ seq 5 ←Outputs 1 to 5 (omitting FIRST and INCREMENT) 1
1
2
3
4
5
$ seq 1 2 5 ←Outputs 1 to 5 with FIRST=1 and INCREMENT=2
1
3
5
$ seq -f"%04g" 1 5 ←Outputs 1 to 5 with a custom format using printf
0001
0002
0003
0004
0005
$ seq -s "`echo -e "\t"`" 0 5 ←Outputs 0 to 5 with tab (\t) as a separator
0       1       2       3       4       5
$ seq -w 98 100 ←Outputs 98 to 100 with a fixed width
098
099
100
$ seq 1 3 | tac ← Counts down using the "tac" command
3
2
1

For more examples, you can refer to the provided link.