Linux seq命令的使用详解
更新时间:2020年02月17日 12:14:21 作者:沧海一笑-dj
这篇文章主要介绍了Linux seq命令的使用详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
01. 命令概述
seq命令用于产生整数序列。
02. 命令格式
用法:
seq [选项]... 尾数 seq [选项]... 首数 尾数 seq [选项]... 首数 增量 尾数
03. 常用选项
以指定增量从首数开始打印数字到尾数。
-f, --format=格式 使用printf 样式的浮点格式 -s, --separator=字符串 使用指定字符串分隔数字(默认使用:\\n) -w, --equal-width 在列前添加0 使得宽度相同 --help 显示此帮助信息并退出 --version 显示版本信息并退出
04. 参考示例
4.1 输出1-5
[deng@localhost ~]$ seq 5 1 2 3 4 5 [deng@localhost ~]$
4.2 输出1-5
[deng@localhost ~]$ seq 1 5 1 2 3 4 5 [deng@localhost ~]$
4.3 输出3-5
[deng@localhost ~]$ seq 3 5 3 4 5 [deng@localhost ~]$
4.4 输出1 4 7 10
[deng@localhost ~]$ seq 1 3 10 1 4 7 10 [deng@localhost ~]$
4.5 指定格式输出
[deng@localhost ~]$ seq -f "%3g" 9 11 9 10 11 [deng@localhost ~]$
意思是-f指定格式,%后面指定3位数,默认是%g,%3g不够位数的地方都是空格填补
4.6 指定格式输出
[deng@localhost ~]$ seq -f "%03g" 9 11 009 010 011 [deng@localhost ~]$
意思是打印三位,不足的地方用0填补
4.7 指定格式输出
[deng@localhost ~]$ seq -f "str%03g" 9 11 str009 str010 str011 [deng@localhost ~]$
意思是打印三位不足的地方以0填补,在前面加上str
4.8 在列前添加0使得宽度相同
[deng@localhost ~]$ seq -w 9 11 09 10 11 [deng@localhost ~]$
当输出等宽字符串时不应再指定格式字符串,-w与-f不能一起用
4.9 使用指定字符串分隔数字
[deng@localhost ~]$ seq -s " " -f "str%03g" 9 11 str009 str010 str011 [deng@localhost ~]$
4.10 使用tab键分隔数字
[deng@localhost ~]$ seq -s "`echo -e '\\t'`" 9 11 9 10 11 [deng@localhost ~]$
先用命令做成一个tab,然后再指定成分隔符
05. 附录
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持华域联盟。
您可能感兴趣的文章:
相关文章
-
CentOS6.5与CentOS7 ssh修改默认端口号的方法
这篇文章主要介绍了CentOS6.5与CentOS7 ssh修改默认端口号的方法,结合实例形式分别描述了CentOS6.5及CentOS7针对ssh修改默认端口号的具体操作步骤、相关命令与使用技巧,需要的朋友可以参考下2018-04-04
声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

最新评论