cat 把檔案串連接后傳到標(biāo)準(zhǔn)輸出
參數(shù):
-n 或 --number 由 1 開始對(duì)所有輸出的行數(shù)編號(hào)
-b 或 --number-nonblank 和 -n 相似,只不過對(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,那么接下來,你輸入什么,會(huì)立即顯示什么,直到ctrl+D結(jié)束文件輸入
cat > junk
參數(shù):
-n 或 --number 由 1 開始對(duì)所有輸出的行數(shù)編號(hào)
-b 或 --number-nonblank 和 -n 相似,只不過對(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,那么接下來,你輸入什么,會(huì)立即顯示什么,直到ctrl+D結(jié)束文件輸入
cat > junk