linux命令之nl
linux命令nl用来将输出的文件内容自动加上行号
nl [参数] filename
| 参数 | 说明 |
| -b a | 输出内容都加上行号 |
| -b t | 只有非空行的输出加上行号,默认选项 |
| -n ln | 在最左方加上行号 |
| -n rn | 在最右方加上行号,且不加0 |
| -n rz | 在最右方加上行号,且加0 |
| -w | 行号字段占用的字符数,默认为6位数 |
命令:
nl /etc/issue
- [root@centos79-3 ~]# nl /etc/issue
- 1 \S
- 2 Kernel \r on an \m
-
- [root@centos79-3 ~]#
命令:
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 ~]#
命令:
nl -n ln /etc/issue
- [root@centos79-3 ~]# nl -n ln /etc/issue
- 1 \S
- 2 Kernel \r on an \m
-
- [root@centos79-3 ~]#
命令:
nl -n rn /etc/issue
- [root@centos79-3 ~]# nl -n rn /etc/issue
- 1 \S
- 2 Kernel \r on an \m
-
- [root@centos79-3 ~]#
命令:
nl -n rz /etc/issue
- [root@centos79-3 ~]# nl -n rz /etc/issue
- 000001 \S
- 000002 Kernel \r on an \m
-
- [root@centos79-3 ~]#
命令:
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 ~]#