51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

linux seq命令详解

linux seq命令详解

seq - print a sequence of numbers

意思就是:

产生从某个数到另外一个数之间的所有整数

例如:

用法1

seq 10

结果如下:

用法2

平时我们用的比较多的参数 是 -s (使用指定的字符串分割数字(默认使用个"\n"分割))

seq -s + 10

结果:

其他用法:

用法3

产生-2~10内的整数,增量为2

seq -2 2 10

用法4

产生98~101之间的整数,并且要求输出数字宽度相同,不足的用空格补足。

seq -f "%3g" 98 100

其他的可以参考 帮助信息


NAME
       seq - print a sequence of numbers

SYNOPSIS seq [OPTION]... LAST seq [OPTION]... FIRST LAST seq [OPTION]... FIRST INCREMENT LAST

DESCRIPTION Print numbers from FIRST to LAST, in steps of INCREMENT.

   Mandatory arguments to long options are mandatory for short options too.

-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

--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

赞(12)
未经允许不得转载:工具盒子 » linux seq命令详解