關于此命令,有人認為寫 cat 命令的人是因為喜歡貓,因此給此命令起名為“cat”,其實不然,cat 是 concatenate(連接、連續)的簡寫。
cat 命令的基本格式如下:[root@localhost ~]# cat [選項] 文件名
或者
[root@localhost ~]# cat 文件1 文件2 > 文件3
| 選項 | 含義 |
|---|---|
| -A | 相當于 -vET 選項的整合,用于列出所有隱藏符號; |
| -E | 列出每行結尾的回車符 $; |
| -n | 對輸出的所有行進行編號; |
| -b | 同 -n 不同,此選項表示只對非空行進行編號。 |
| -T | 把 Tab 鍵 ^I 顯示出來; |
| -V | 列出特殊字符; |
| -s | 當遇到有連續 2 行以上的空白行時,就替換為 1 行的空白行。 |
PgUp+上箭頭組合鍵向上翻頁,但是這種翻頁是有極限的,如果文件足夠長,那么還是無法看全文件的內容。[root@localhost ~]# cat anaconda-ks.cfg
# Kickstart file automatically generated by anaconda.
#version=DEVEL
install
cdrom
lang zh一CN.UTF-8
…省略部分內容...
[root@localhost ~]# cat -n anaconda-ks.cfg
1 # Kickstart file automatically generated by anaconda.
2
3
4 #version=DEVEL
5 install
6 cdrom
…省略部分內容...
[root@localhost ~]# cat -A anaconda-ks.cfg
# Kickstart file automatically generated by anaconda.$
$
$
#version=DEVEL$
install$
cdrom$
…省略部分內容…
[root@localhost base]# ls
file1.txt file2.txt
[root@localhost base]# cat file1.txt
http://c.biancheng.net(file1.txt)
[root@localhost base]# cat file2.txt
is great(file2.txt)
[root@localhost base]# cat file1.txt file2.txt > file3.txt
[root@localhost base]# more file3.txt
#more 命令可查看文件中的內容
http://c.biancheng.net(file1.txt)
is great(file2.txt)
[root@localhost base]# ls
file1.txt file2.txt file3.txt
新聞熱點
疑難解答