Linux daily learning(1)-nl

nl命令是用来为文本文件生成行号的,但最实用的用法还是在每行之前添加0。

//显示行号,默认空白行不显示
[root@xuxing ~]# nl /etc/fstab
//空白行也显示行号
[root@xuxing ~]# nl -b a  /etc/fstab
//为每行添加0,默认添加5个
[root@xuxing ~]# nl -b a -n rz /etc/fstab
//指定添加3个0,使用"-w 3"
[root@xuxing ~]# nl -b a -n rz -w 3 /etc/fstab



//示例
[root@xuxing ~]# nl -b a -n rz /etc/fstab
000001  
000002  #
000003  # /etc/fstab
000004  # Created by anaconda on Wed Dec 19 08:07:14 2018
000005  #
000006  # Accessible filesystems, by reference, are maintained under '/dev/disk'
000007  # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
000008  #
000009  /dev/mapper/centos-root /                       xfs     defaults        0 0
000010  UUID=bd47b365-3718-40a2-a835-e6ae1c5187c5 /boot                   xfs     defaults        0 0
000011  /dev/mapper/centos-swap swap                    swap    defaults        0 0
[root@xuxing ~]#

Xu

Step by step the ladder is ascended.

“Only for self-learning use, if infringement will delete.”

Tags:

           

No comments

Comments feed for this article

Reply

Your email address will not be published. Required fields are marked *