Linux命令(101)之nl
  wwLZeziuqjLR 2023年11月02日 52 0


linux命令之nl

1.nl 介绍

linux命令nl用来将输出的文件内容自动加上行号

2.nl用法

nl [参数] filename

nl常用参数

参数

说明

-b a

输出内容都加上行号

-b t

只有非空行的输出加上行号,默认选项

-n ln

在最左方加上行号

-n rn

在最右方加上行号,且不加0

-n rz

在最右方加上行号,且加0

-w

行号字段占用的字符数,默认为6位数

3.实例

3.1.显示/etc/issue文件的内容

命令:

nl /etc/issue

[root@centos79-3 ~]# nl /etc/issue
     1	\S
     2	Kernel \r on an \m
       
[root@centos79-3 ~]#

3.2.输出/etc/issue文件内容都加上行号

命令:

nl -b a /etc/issue

[root@centos79-3 ~]# nl -b a /etc/issue
     1	\S
     2	Kernel \r on an \m
     3	
[root@centos79-3 ~]#

3.3.输出/etc/issue文件内容,并在最左方加上行号

命令:

nl -n ln /etc/issue

[root@centos79-3 ~]# nl -n ln /etc/issue
1     	\S
2     	Kernel \r on an \m
       
[root@centos79-3 ~]#

3.4.输出/etc/issue文件内容,并在最右方加上行号(不加0)

命令:

nl -n rn /etc/issue

[root@centos79-3 ~]# nl -n rn /etc/issue
     1	\S
     2	Kernel \r on an \m
       
[root@centos79-3 ~]#

3.5.输出/etc/issue文件内容,并在最右方加上行号(加0)

命令:

nl -n rz /etc/issue

[root@centos79-3 ~]# nl -n rz /etc/issue
000001	\S
000002	Kernel \r on an \m
       
[root@centos79-3 ~]#

3.6.输出/etc/issue文件内容,并在最右方加上行号(加0),且字段位数为4位

命令:

nl -n rz -w 4 /etc/issue

[root@centos79-3 ~]# nl -n rz -w 4 /etc/issue
0001	\S
0002	Kernel \r on an \m
     
[root@centos79-3 ~]#
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
wwLZeziuqjLR