1.释义
将指定的各个文件添加行号标注后写到标准输出
2.系统帮助
用法:nl [选项]... [文件]...
Write each FILE to standard output, with line numbers added.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
-b, --body-numbering=样式使用指定样式编号文件的正文行目
-d, --section-delimiter=CC使用指定的CC 分割逻辑页数
-f, --footer-numbering=样式使用指定样式编号文件的页脚行目
-h, --header-numbering=样式使用指定样式编号文件的页眉行目
-i, --page-increment=数值设置每一行遍历后的自动递增值
-l, --join-blank-lines=数值设置数值为多少的若干空行被视作一行
-n, --number-format=格式根据指定格式插入行号
-p, --no-renumber在逻辑页数切换时不将行号值复位
-s, --number-separator=字符串可能的话在行号后添加字符串
-v, --starting-line-number=数字每个逻辑页上的第一行的行号
-w, --number-width=数字为行号使用指定的栏数
--help显示此帮助信息并退出
--version显示版本信息并退出
默认的选项设置是-v1 -i1 -l1 -sTAB -w6 -nrn -hn -bt -fn。CC 是用于分隔
逻辑页数的两个分界符,其中缺失的第二个字符暗含了":",如果您要指定"\",
请输入"\\"。可用的样式如下:
a对所有行编号
t对非空行编号
n不编行号
pBRE只对符合正则表达式BRE 的行编号
FORMAT 是下列之一:
ln左对齐,空格不用0 填充
rn 右对齐,空格不用0 填充
rz 右对齐,空格用0 填充
GNU coreutils online help:
请向 报告nl 的翻译错误
要获取完整文档,请运行:info coreutils 'nl invocation'
3.示例
3.1.默认
nl /etc/passwd
3.2.空行也带序号
[root@itbkz.com s]#cat test.txt
abc
def
ghi
[root@itbkz.com s]#nl -b a test.txt
1abc
2
3def
4
5ghi
3.3.左对齐空格不用0填充
[root@itbkz.com s]#nl -n ln test.txt
1 abc
2 def
3 ghi
3.4.右对齐空格不用0填充
[root@itbkz.com s]#nl -n rn test.txt
1abc
2def
3ghi
3.5.右对齐空格使用0填充
[root@itbkz.com s]#nl -n rz test.txt
000001abc
000002def
000003ghi
IT博客站版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:nl命令将指定的各个文件添加行号编号序号标注后写到标准输出