(六)直接检视档案内容 :cat/tac/nl

cat  

  写法:cat [-参数]

参数:

  -A:相当于-vET的整合参数,可以列出一些特殊字符

  -E:将结尾的断行字符$显示出来

  -n:打印出行号

  -T:将[tab]按键以^I显示出来

  -v:列出一些看不出来的特殊字符

实例:检阅/etc/issue这个档案的内容,打印出行号

1 [root@localhost ~]# cat /etc/issue   //查看该目录的内容
2 CentOS Linux release 6.0 (Final)
3 Kernel \r on an \m
4 
5 [root@localhost ~]# cat -n /etc/issue  //查看该目录的内容且输入行号
6      1  CentOS Linux release 6.0 (Final)
7      2  Kernel \r on an \m
8      3

实例:将 /etc/xinetd.comf的内容完整显示出来(包含特殊字符)

 1 [root@localhost ~]# cat -A /etc/xinetd.conf
 2 #$
 3 # This is the master xinetd configuration file. Settings in the$
 4 # default section will be inherited by all service configurations$
 5 # unless explicitly overridden in the service configuration. See$
 6 # xinetd.conf in the man pages for a more detailed explanation of$
 7 # these attributes.$
 8 $
 9 defaults$
10 {$
11 # The next two items are intended to be a quick access place to$
12 # temporarily enable or disable services.$
13 #$
14 #^Ienabled^I^I=$
15 #^Idisabled^I=$
16 $
17 # Define general logging characteristics.$
18 ^Ilog_type^I= SYSLOG daemon info $
19 ^Ilog_on_failure^I= HOST$
20 ^Ilog_on_success^I= PID HOST DURATION EXIT$
21 $
22 # Define access restriction defaults$
23 #$
24 #^Ino_access^I=$
25 #^Ionly_from^I=$
26 #^Imax_load^I= 0$
27 ^Icps^I^I= 50 10$
28 ^Iinstances^I= 50$
29 ^Iper_source^I= 10$
30 $
31 # Address and networking defaults$
32 #$
33 #^Ibind^I^I=$
34 #^Imdns^I^I= yes$
35 ^Iv6only^I^I= no$
36 $
37 # setup environmental attributes$
38 #$
39 #^Ipassenv^I^I=$
40 ^Igroups^I^I= yes$
41 ^Iumask^I^I= 002$
42 $
43 # Generally, banners are not used. This sets up their global defaults$
44 #$
45 #^Ibanner^I^I=$
46 #^Ibanner_fail^I=$
47 #^Ibanner_success^I=$
48 }$
49 $
50 includedir /etc/xinetd.d$
51  $
52
53 //   [tab]按键以^I显示
54 //   在linux是以$为断行字符,windows是以^M$为断言字符
55 

tac(反向显示)

cat:第一行到最后一行显示

tac:最后一行到第一行反向显示

1 [root@localhost ~]# tac /etc/issue
2 
3 Kernel \r on an \m
4 CentOS Linux release 6.0 (Final)

nl(添加行号打印)

写法: nl [-参数] 档案

参数:

 -b:指定行号指定的方式,主要有两种:

  -b a:表示不论是否为空行,也同样列出行号

  -b t:如果有空格,空的那一行不要列出行号

   -n:列出行号表示方法,主要有三种:

  -n ln:行号在屏幕的最左方显示

  -n rn:行号在自己字段的最右方显示,且不加0

  -n rz:行号在自己字段的最右方显示,且加0

   -w:行号字段的占有的位数

 1 [root@localhost ~]# nl /etc/issue   //添加行号打印该文件(第三行没有行号)
 2      1  CentOS Linux release 6.0 (Final)
 3      2  Kernel \r on an \m
 4        
 5 [root@localhost ~]# nl -b a /etc/issue    // 不论是否为空行,都打印出行号
 6      1  CentOS Linux release 6.0 (Final)
 7      2  Kernel \r on an \m
 8      3
 9 [root@localhost ~]# nl -b a -n rz /etc/issue //在前面自动补上0(预设字段为6位数)
10 000001  CentOS Linux release 6.0 (Final)
11 000002  Kernel \r on an \m
12 000003
13 [root@localhost ~]# nl -b a -n rz -w 3 /etc/issue  //在前面自动补上0,且位数为3位
14 001     CentOS Linux release 6.0 (Final)
15 002     Kernel \r on an \m
16 003
17 [root@localhost ~]# nl -b a -n rz -w 2 /etc/issue   //在前面自动补上0,且位数为2位
18 01      CentOS Linux release 6.0 (Final)
19 02      Kernel \r on an \m
20 03
21 [root@localhost ~]# 

 

posted @ 2015-08-27 16:19  花花妹子。  阅读(210)  评论(0)    收藏  举报