nl (Number of Lines) 将指定的文件添加行号标注后写到标准输出。若是不指定文件或指定文件为"-" ,程序将从标准输入读取数据。正则表达式
nl [选项]... [文件]...
-b, --body-numbering=样式 使用指定样式编号文件的正文行目 -d, --section-delimiter=CC 使用指定的CC 分割逻辑页数 -f, --footer-numbering=样式 使用指定样式编号文件的页脚行目 -h, --header-numbering=样式 使用指定样式编号文件的页眉行目 -i, --page-increment=数值 设置每一行遍历后的自动递增值 -l, --join-blank-lines=数值 设置数值为多少的若干空行被视做一行-n, --number-format= 格式 根据指定格式插入行号
[root@oracledb study]# nl test1.log 1 2011 2 2012 3 2013
[root@oracledb study]# nl -nln test1.log 1 2011 2 2012 3 2013 [root@oracledb study]# nl -nrn test1.log 1 2011 2 2012 3 2013 [root@oracledb study]# nl -nrz test1.log 000001 2011 000002 2012 000003 2013
[root@oracledb study]# nl -nrz -w 4 test1.log 0001 2011 0002 2012 0003 2013
[root@oracledb study]# nl line1 1 line1 line2 2 line2 line3 3 line3 [root@oracledb study]#
[root@oracledb study]# nl <<EOF > line1 > line2 > line3 > EOF 1 line1 2 line2 3 line3