Detailed explanation of seq command in shell

seq is used to generate all integers from one number to another.

#seq 1 5 Generate numbers 1 to 5

1

2

3

4

5

Usage: seq [option] ... mantissa
 or: seq [option] ... mantissa mantissa
 or: seq [option] ... mantissa increment mantissa

Options:

     -f, --format=FORMAT      use printf style floating-point FORMAT
     -s, --separator=STRING   use STRING to separate numbers (default: \n)
    -w, --equal-width        equalize width by padding with leading zeroes

 

-f specifies the output format

#seq -f "% 3g" 13 The number of digits is three, less than spaces

  1

  2

  3

#seq -f "% 03g" 1 5 The number of digits is three, less than zero

001

002

003

004

005

#seq -f "str%03g" 1 3

str001

str002

str003

 

-w specifies that the output digits have the same width, similar to the -f part, and cannot be used together with the -f option

#seq -w  8 12

08

09

10

11

12

 

-s specifies the separator, the default separator is / n (carriage return)

#seq -s "" 15 spaces as separators

1 2 3 4 5 

#seq -s "` echo -e "\ t" `" 1 3 \ t as a separator

1  2    3

Guess you like

Origin www.cnblogs.com/xiaoyuxixi/p/12739468.html