seq command instructions

1, Command Overview

seq command for generating the number of all integers from one to another between the number (positive or negative).

2, the command syntax

seq [options] Parameters 
seq [options] ... ending in
seq [options] ... the first few mantissa
seq [options] ... the first few increments mantissa (seq initial value increment termination value)

3, command options

-f: printf style using floating point format (without the specified format, default format is '% G')
-s: string specified partition number (default: \ n)
is added before column: -w 0 such that the same width (auto fill bits)

4, an example of command

 4.1 default output:

. 1 [LZG the root @ ~] SEQ # . 5 # output from an integer between 1. 5 
2  . 1 
. 3  2 
. 4  . 3 
. 5  . 4 
. 6  . 5 
. 7 [LZG the root @ ~] SEQ # . 4  . 8 # output integer 4-8 
. 8  . 4 
. 9  . 5 
10  . 6 
. 11  . 7 
12 is  . 8 
13 is [the root LZG @ ~] SEQ # 1  2  10 # 1 begins to increase from the second input to the end 10. Increment can be an integer can also be a decimal. 
14  . 1 
15  . 3 
16  . 5 
. 17  . 7 
18 is  . 9

 

. 1 [LZG the root @ ~] SEQ # - . 3  . 1 
2 - . 3 
. 3 - 2 
. 4 - . 1 
. 5  0 
. 6  . 1 
. 7 [LZG the root @ ~] SEQ # 1.1  . 5 # default increment of 1 
. 8  1.1 
9  2.1 
10  3.1 
11  4.1 
12 is [the root LZG @ ~] SEQ # 1.1  0.2  2 0.2 # increment designated 
13  1.1 
14  1.3 
15  1.5 
16  1.7 
17  1.9

 

4.2 -s: string specified partition number (the default: \ n):

 1 [root@lzg ~]# seq -s "#" 5       #用#号间隔
 2 1#2#3#4#5
 3 [root@lzg ~]# seq -s "#" 2 5
 4 2#3#4#5
 5 [root@lzg ~]# seq -s "#" 1 2 10
 6 1#3#5#7#9
 7 [root@lzg ~]# seq -s " " # 5 with a space between 
. 8  . 1  2  . 3  . 4  5 
. 9 [LZG the root @ ~] -s SEQ # "  "  2  5 
10  2  . 3  . 4  5 
. 11 [LZG the root @ ~] -s SEQ # "  "  . 1  2  10 
12 is  . 1  . 3  . 5  . 7  . 9 
13 is [the root LZG @ ~] -s SEQ # " dd "  . 5 # string dd spacer 
14  1dd2dd3dd4dd5
 15 [LZG the root @ ~] -s SEQ # " dd "  2  . 5 
16  2dd3dd4dd5
 . 17 [root@lzg ~]# seq -s "dd" 1 2 10
18 1dd3dd5dd7dd9
[LZG the root @ ~] -s SEQ # " ` echo -e " \ T " ` "  . 1  2  . 5 # using tabs, invoke the command 
. 1     . 3     . 5

4.3 -w: Add 0 so that the same width (auto fill bits) before the column:

 1 [root@lzg ~]# seq -w 8 11
 2 08
 3 09
 4 10
 5 11
 6 [root@lzg ~]# seq -w 98 101
 7 098
 8 099
 9 100
10 101

4.4 Output integer between 98 to 101, and require the same width of the output digital insufficient padded with spaces.

[LZG the root @ ~] -f SEQ # " % 3G "  98  101 # ( "3G%" indicates that the specified format "bit width" is three, the number of digits less than partially fill a space bit) 
 98 
 99 
100 
101 
[ @ LZG the root ~] -f SEQ # " % 5g "  98  101 # ( "% 5g" this format specifies "bit width" is five, the number of digits less than partially fill a space bit) can be seen both in front of space 
   98 
   99 
  100 
  101
[LZG the root @ ~] -f SEQ # " % 03G "  98  101 # ( "% 03G" This format specifies "bit width" is three, the number of digits less than 0 part by fill bits, by adding the 0% alternative spaces make up the vacancies), equivalent to the -w option. 
098 
099 
100 
101 
[LZG the root @ ~] -f SEQ # " % 05g "  98  101 # ( "% 05g" This format specifies "bit width" is five, the number of digits less than a portion of fill bits 0 through Alternatively spaces after adding make up 0% vacancy) 
00098 
00099 
00100 
00101

Note:% fact preceding string can be specified, the same can also be specified later g string:

[root@lzg ~]# seq -f "as%g" 98 101
as98
as99
as100
as101
[root@lzg ~]# seq -f "as%03g" 98 101
as098
as099
as100
as101
[root@lzg ~]# seq -f "as%02gaa" 4
as01aa
as02aa
as03aa
as04aa

Using this method you can create a file or directory:

[root@lzg ~]# touch $(seq -f "test%02g.txt" 4)
[root@lzg ~]# ls
test01.txt  test02.txt  test03.txt  test04.txt
[root@lzg ~]# mkdir $(seq -f "dir_%02g" 4)
[root@lzg ~]# ls
dir_01  dir_02  dir_03  dir_04  test01.txt  test02.txt  test03.txt  test04.txt

 

 

Guess you like

Origin www.cnblogs.com/liuzgg/p/11865430.html