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: <http://www.gnu.org/software/coreutils/> 请向<http://translationproject.org/team/zh_CN.html> 报告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 1 abc 2 3 def 4 5 ghi
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 1 abc 2 def 3 ghi
3.5.右对齐空格使用0填充
[root@itbkz.com s]#nl -n rz test.txt 000001 abc 000002 def 000003 ghi