cat 和 nl

1522阅读 0评论2011-03-09 zzy7186
分类:LINUX

cat 要显示行号的话得加上-n (显示空行行号) –b (不显示空行行号)

如:

[root@Server1 shelllearn]#cat a
hello   world!

xdimh

[root@Server1 shelllearn]#cat -b a
     1  hello   world!

     2  xdimh

[root@Server1 shelllearn]#cat -n a
     1  hello   world!
     2
     3  xdimh

但是不能对行号进行操作比如想让行号在第一列,这是就可以通过nl

nl可以自动输出行号

[root@Server1 shelllearn]#nl a
     1  hello   world!

     2  xdimh

对行号的输出有是那种格式

通过选项-n指定

三个参数

ln rn 和 rz

[root@Server1 shelllearn]#nl -n ln a
1       hello   world!

2       xdimh
[root@Server1 shelllearn]#man nl
[root@Server1 shelllearn]#nl -n rn a
     1  hello   world!

     2  xdimh
[root@Server1 shelllearn]#nl -n rz a
000001  hello   world!

000002  xdimh

-b 选项的两个参数

t

a

[root@Server1 shelllearn]#nl -b a a
     1  hello   world!
     2
     3  xdimh
[root@Server1 shelllearn]#nl -b t a
     1  hello   world!

     2  xdimh

-w 选项

行号占几列

[root@Server1 shelllearn]#nl -n rz -w 2 a
01      hello   world!

02      xdimh

上一篇:rename 简单使用
下一篇:chattr 与 lsattr