深入解析Linux 常用命令--cat

来源:互联网 发布:5sing音乐软件 编辑:程序博客网 时间:2024/06/05 17:06

深入解析Linux常用命令–cat

1.概述

cat常用于查看文件内容。

2.显示文件内容(显示字符)

cat -A 显示文件内容,包括结束符、TAB。其中结束符以$显示,TAB以^I显示,空格不显示。

[root@smart Desktop]# cat test.mdAUTHOR       Written by Richard M. Stallman and David MacKenzie.[root@smart Desktop]# cat -A test.mdAUTHOR$^IWritten by Richard M. Stallman and David MacKenzie.$$

3.显示行号

cat -b 显示非空行行号

cat -n 显示所有行行号

[root@smart Desktop]# cat -b test.md     1  AUTHOR     2         Written by Richard M. Stallman and David MacKenzie.     3  REPORTING BUGS     4         Report ls bugs to bug-coreutils@gnu.org     5         GNU coreutils home page: <http://www.gnu.org/software/coreutils/>     6         General help using GNU software: <http://www.gnu.org/gethelp/>     7         Report ls translation bugs to <http://translationproject.org/team/>[root@smart Desktop]# cat -n test.md     1  AUTHOR     2         Written by Richard M. Stallman and David MacKenzie.     3       4  REPORTING BUGS     5         Report ls bugs to bug-coreutils@gnu.org     6         GNU coreutils home page: <http://www.gnu.org/software/coreutils/>     7         General help using GNU software: <http://www.gnu.org/gethelp/>     8         Report ls translation bugs to <http://translationproject.org/team/>

4.显示特殊字符

cat -E ,以$显示结束符,此时不会显示TAB字符。

cat -T,以^I显示TAB字符。

[root@smart Desktop]# cat -E test.mdAUTHOR$    Written by Richard M. Stallman and David MacKenzie.$[root@smart Desktop]# cat -T test.mdAUTHOR^IWritten by Richard M. Stallman and David MacKenzie.   

Juyin@2017/12/22

原创粉丝点击