Zhang Jiuan’ Notes

linux seq更为详细的用法

 

以前使for i in提时候对于01 11而烦恼,可查了一把seq,发现还有其它的特点。
seq命令的作用就是打印出一串有序的数字,它主要有以下3个参数构成:

       -f, –format=FORMAT 
              use printf style floating-point FORMAT (default: %g)

-f 指定打印的格式:
例如:
[root@hao32]# seq -f %05g 2 7 
00002
00003
00004
00005
00006
00007

       -s, –separator=STRING
              use STRING to separate numbers (default: \n)
-s 指定分隔符 默认是回车:
例如:
[root@hao32]# seq -s” ” 2 7
2 3 4 5 6 7

       -w, –equal-width
              equalize width by padding with leading zeroes
-w 输出是同宽 前面不足的用 “0″ 补全,即与位数最多的数对齐
例如:
[root@hao32]# seq -w 2 11
02
03
04
05
06
07
08
09
10
11

转自:记不清了

 

多谢

张久安

If you enjoyed this post, make sure you subscribe to my RSS feed!

No Comments, Comment or Ping

Reply to “linux seq更为详细的用法”

You must be logged in to post a comment.

返回顶部