Linux cat命令

cat可以从文件中和stdin中读取,从stdin中读取:

[student@myhost ~]$ echo hhh | cat
hhh

拼接stdin和文件中的内容:

[student@myhost ~]$ echo hhh | cat - a
hhh
A line in file.

压缩文件中的空白行(多个空白行改为一个):

[student@myhost ~]$ cat a
line1


line4

line6
[student@myhost ~]$ cat -s a
line1

line4

line6

将文件中的制表符和空格分辨出来(着重分辨制表符,会显示为^I,在python程序中可能会很有用):

[student@myhost ~]$ cat a
space: 
tab:	
[student@myhost ~]$ cat -T a
space: 
tab:^I

输出行号:

[student@myhost ~]$ cat -n a
     1	space: 
     2	tab:	
posted @ 2019-01-22 23:36  epiphanyy  阅读(9)  评论(0)    收藏  举报  来源