每日一個(gè)linux命令09-cat

1. 命令解析

命令用途

  1. 顯示整個(gè)文件的內(nèi)容;
  2. 創(chuàng)建一個(gè)新文件,并從鍵盤向文件輸入內(nèi)容;
  3. 將幾個(gè)文件的內(nèi)容合并到一個(gè)新文件;

命令格式

cat [OPTION]... FILE...

命令參數(shù)

-A, --show-all equivalent to -vET
-b, --number-nonblank number nonempty output lines, overrides -n
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-s, --squeeze-blank suppress repeated empty output lines
-t equivalent to -vT
-T, --show-tabs display TAB characters as ^I
-u (ignored)
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
--help display this help and exit
--version output version information and exit

2. 示例

2.1 顯示文件內(nèi)容

[root@test catTest]# cat f1
Hello
This
is
My
Password=${pwd}

2.2 創(chuàng)建一個(gè)新文件,使用here doc的方式錄入內(nèi)容

[root@test catTest]# cat <<EOF > f3
> This
> is
> f3
> EOF
[root@test catTest]# cat f3
This
is
f3

2.3 顯示文件內(nèi)容并標(biāo)出行號,包括空行 -n

[root@test catTest]# cat -n f3
     1  This
     2  is
     3  f3
     4  
     5  
     6  After blank is
     7  new line
     8  

2.4 顯示文件內(nèi)容并標(biāo)出行號,不包括空行 -b

root@test catTest]# cat -b f3
     1  This
     2  is
     3  f3


     4  After blank is
     5  new line

2.5 合并文件

root@test catTest]# cat f1 f3 > f4

2.6 倒序輸出

[root@test catTest]# cat f3
This
is
f3


After blank is
new line

[root@test catTest]# tac f4

new line
After blank is


f3
is
This
this is f1\n

2.7 在顯示每行的結(jié)尾時(shí)附加$ -E

[root@test catTest]# cat -ET f4
this is f1\n$
This$
is$
f3$
$
$
After blank is$
new line$
$

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 轉(zhuǎn)載來自鏈接:真機(jī)測試Could not find Developer Disk Image - CCSS'S B...
    墨狂之逸才閱讀 18,637評論 0 51
  • 午夜夢醒,下意識的按下開關(guān)。溫和的暖光占據(jù)了房間。 這個(gè)城市的氣候變化無常,初秋的腳步剛剛到來,刺骨的寒意就已...
    千音百調(diào)閱讀 487評論 0 1
  • 我是誰? 我是一個(gè)與眾不同的人,上小學(xué)的時(shí)候我就告訴自己。后來明白了每個(gè)人都是這么想的,每個(gè)人都想做不平凡的人。 ...
    Flora唐閱讀 327評論 1 1
  • 提權(quán)繼承的問題: 1.是哪個(gè)用戶運(yùn)行的程序,提權(quán)后就是該用戶的權(quán)限,可利用 ps -aux查看運(yùn)行程序的所有者 2...
    xiaobaozi閱讀 420評論 0 0
  • 風(fēng)暈桂飄香, 沉醉煙路殤。 可嘆念時(shí)蕩, 遙托明月疆。
    萬俟蘇蘇閱讀 273評論 0 0

友情鏈接更多精彩內(nèi)容