使用方式:cat [-AbeEnstTuv] [--help] [--version] fileName
說(shuō)明:把檔案串連接后傳到基本輸出(顯示器或加 > fileName 到另一個(gè)檔案) 參數(shù): -n 或 --number 由 1 開(kāi)始對(duì)所有輸出的行數(shù)編號(hào) -b 或 --number-nonblank 和 -n 相似,只不過(guò)對(duì)于空白行不編號(hào) -s 或 --squeeze-blank 當(dāng)遇到有連續(xù)兩行以上的空白行,就代換為一行的空白行 -v 或 --show-nonprinting 范例: cat -n textfile1 > textfile2 把 textfile1 的檔案內(nèi)容加上行號(hào)后輸入 textfile2 這個(gè)檔案里 cat -b textfile1 textfile2 >> textfile3 把 textfile1 和 textfile2 的檔案內(nèi)容加上行號(hào)(空白行不加)之后將內(nèi)容附加到 textfile3 里。 范例: 把 textfile1 的檔案內(nèi)容加上行號(hào)后輸入 textfile2 這個(gè)檔案里 cat -n textfile1 > textfile2 把 textfile1 和 textfile2 的檔案內(nèi)容加上行號(hào)(空白行不加)之后將內(nèi)容附加到 textfile3 里。 cat -b textfile1 textfile2 >> textfile3 cat /dev/null > /etc/test.txt 此為清空/etc/test.txt檔案內(nèi)容 cat 也可以用來(lái)制作 image file。例如要制作軟碟的 image file,將軟碟放好后打 cat /dev/fd0 > OUTFILE 相反的,如果想把 image file 寫(xiě)到軟碟,請(qǐng)打 cat IMG_FILE > /dev/fd0 注: 1. OUTFILE 指輸出的 image 檔名。 2. IMG_FILE 指 image file。 3. 若從 image file 寫(xiě)回 device 時(shí),device 容量需與相當(dāng)。 4. 通常用在制作開(kāi)機(jī)磁片。 cat主要有三大功能: 1.一次顯示整個(gè)文件。$ cat filename
2.從鍵盤創(chuàng)建一個(gè)文件。$ cat > filename 只能創(chuàng)建新文件,不能編輯已有文件. :z)
3.將幾個(gè)文件合并為一個(gè)文件。 $cat file1 file2 > file" 參數(shù):
-n 或 --number 由 1 開(kāi)始對(duì)所有輸出的行數(shù)編號(hào)
-b 或 --number-nonblank 和 -n 相似,只不過(guò)對(duì)于空白行不編號(hào) |,3S
-s 或 --squeeze-blank 當(dāng)遇到有連續(xù)兩行以上的空白行,就代換為一行的空白行 -v 或 --show-nonprinting
|
|
來(lái)自: Suzy周 > 《Linux/Unix》