cat

cat(选项)(参数) 显示文件的内容,tac为cat的反向输出

-b:为非空行编号

[root@bogon admin]# cat -b a
     1	hive:x:5000:5000:hive:/home/hive:/bin/bash

     2	u2:x:5003:5004::/home/u2:/bin/bash
     3	u3:x:5004:5005::/home/u3:/bin/bash
     4	      user1:x:5005:5007::/home/user1:/bin/bash
     5	user2:x:5006:5008::/home/user2:/bin/bash

 -e或-E:为每行行尾添加个$

[root@bogon admin]# cat -e a
hive:x:5000:5000:hive:/home/hive:/bin/bash$
$
u2:x:5003:5004::/home/u2:/bin/bash$
u3:x:5004:5005::/home/u3:/bin/bash$
      user1:x:5005:5007::/home/user1:/bin/bash$
user2:x:5006:5008::/home/user2:/bin/bash$

 -n:为每一行编号,包括空行

[root@bogon admin]# cat -n a
     1	hive:x:5000:5000:hive:/home/hive:/bin/bash
     2	
     3	u2:x:5003:5004::/home/u2:/bin/bash
     4	u3:x:5004:5005::/home/u3:/bin/bash
     5	      user1:x:5005:5007::/home/user1:/bin/bash
     6	user2:x:5006:5008::/home/user2:/bin/bash

 -s:将所有连续的空白行都转换为一行

[root@bogon admin]# cat -n b
     1	q
     2	w
     3	
     4	
     5	e
     6	r
     7	
     8	
     9	t
[root@bogon admin]# cat -ns b
     1	q
     2	w
     3	
     4	e
     5	r
     6	
     7	t

 -t或-T:将制表符tab键转换为^I

[root@bogon admin]# cat -t c
^Ithis is a table^I^I

 

 

 

扩展:

1.将b文件和c文件合并到c,并显示

[root@bogon admin]# cat b c > d
[root@bogon admin]# cat d
q
w


e
r


t
	this is a table		

 

posted @ 2017-12-25 15:44  ForLivetoLearn  阅读(233)  评论(0编辑  收藏  举报