seq command summary of linux command
Function:
The seq command is used to generate all integers from one number to another.
grammar:
1 2 3 |
seq [options]... mantissa seq [options]... leading number mantissa seq [options]... first increment mantissa |
Options:
1 2 3 |
-f, --format=format uses printf-style floating point format -s, --separator=string Use the specified string to separate numbers (default: \n) -w, --equal-width prepend 0 to columns to make width equal |
Example:
-f option: specify the format
1 2 3 4 |
[root@Gin scripts]# seq -f "%3g" 9 11 9 10 11 |
The number of digits specified after % is %g by default , and if %3g is used, the part with insufficient digits is a space.
1 2 3 4 |
[root@Gin scripts]# seq -f "str%03g" 9 11 str009 str010 str011 |
In this case, the insufficient number of digits is 0 , and the character string is specified in front of % .
-w option: specify the same width as the output numbers
1 2 3 4 5 |
[root@Gin scripts]# seq -w 98 101 098 099 100 101 |
Cannot be used with -f , the output is the same width.
-s option: specify the separator (default is carriage return)
1 2 |
[root@Gin scripts]# seq -s" " -f"str%03g" 9 11 str009 str010 str011 |
Specify /t as the delimiter
1 2 |
[root@Gin scripts]# seq -s"`echo -e "/t"`" 9 11 9/t10/t11 |
Specify = as the delimiter:
1 2 |
[root@Gin scripts]# seq -s '=' 1 5 1=2=3=4=5 |
Quote: http://www.cnblogs.com/ginvip/p/6539393.html
Details affect success or failure, thanks to Ginjiu Network for the summary.