seq用法

 

Usage: seq [OPTION]… LAST
or: seq [OPTION]… FIRST LAST
or: seq [OPTION]… FIRST INCREMENT LAST
Print numbers from FIRST to LAST, in steps of INCREMENT.

-f, –format=FORMAT use printf style floating-point FORMAT (default: %g)
-s, –separator=STRING use STRING to separate numbers (default: \n)
-w, –equal-width equalize width by padding with leading zeroes
–help display this help and exit
–version output version information and exit

If FIRST or INCREMENT is omitted, it defaults to 1. That is, an
omitted INCREMENT defaults to 1 even when LAST is smaller than FIRST.
FIRST, INCREMENT, and LAST are interpreted as floating point values.
INCREMENT is usually positive if FIRST is smaller than LAST, and
INCREMENT is usually negative if FIRST is greater than LAST.
When given, the FORMAT argument must contain exactly one of
the printf-style, floating point output formats %e, %f, %g

 

 

demo1#seq -f “%3g+” 0 9

0+
1+
2+
3+
4+
5+
6+
7+
8+
9+

格式化并将前面填充三个空格

demo2#seq -f “%3g” -s, 0 9

0,  1,  2,  3,  4,  5,  6,  7,  8,  9

分割符,默认为\n

 

demo3#seq -s, -w 0 10

00,01,02,03,04,05,06,07,08,09,10

填充前置0和最大值一样的位宽

 

小提示:-w 和 -f不能一起使用,想想其实也是

此条目发表在 bash 分类目录。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*


*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>