linux cat 命令详解
生活随笔
收集整理的這篇文章主要介紹了
linux cat 命令详解
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
linux cat 命令詳解
使用方式:cat [-AbeEnstTuv] [--help] [--version] fileName
說明:把檔案串連接后傳到基本輸出(螢幕或加 > fileName 到另一個檔案)
參數:
-n 或 --number 由 1 開始對所有輸出的行數編號
-b 或 --number-nonblank 和 -n 相似,只不過對于空白行不編號
-s 或 --squeeze-blank 當遇到有連續兩行以上的空白行,就代換為一行的空白行
-v 或 --show-nonprinting
范例:
cat -n textfile1 > textfile2 把 textfile1 的檔案內容加上行號后輸入 textfile2 這個檔案里
cat -b textfile1 textfile2 >> textfile3 把 textfile1 和 textfile2 的檔案內容加上行號(空白行不加)之后將內容附加到 textfile3 里。
范例:
把 textfile1 的檔案內容加上行號后輸入 textfile2 這個檔案里
cat -n textfile1 > textfile2
把 textfile1 和 textfile2 的檔案內容加上行號(空白行不加)之后將內容附加到 textfile3 里。
cat -b textfile1 textfile2 >> textfile3
cat /dev/null > /etc/test.txt 此為清空/etc/test.txt檔案內容
cat 也可以用來制作 image file。例如要制作軟碟的 image file,將軟碟放好后打
cat /dev/fd0 > OUTFILE
相反的,如果想把 image file 寫到軟碟,請打
cat IMG_FILE > /dev/fd0
注:
1. OUTFILE 指輸出的 image 檔名。
2. IMG_FILE 指 image file。
3. 若從 image file 寫回 device 時,device 容量需與相當。
4. 通常用在制作開機磁片。
使用方式:cat [-AbeEnstTuv] [--help] [--version] fileName
說明:把檔案串連接后傳到基本輸出(螢幕或加 > fileName 到另一個檔案)
參數:
-n 或 --number 由 1 開始對所有輸出的行數編號
-b 或 --number-nonblank 和 -n 相似,只不過對于空白行不編號
-s 或 --squeeze-blank 當遇到有連續兩行以上的空白行,就代換為一行的空白行
-v 或 --show-nonprinting
范例:
cat -n textfile1 > textfile2 把 textfile1 的檔案內容加上行號后輸入 textfile2 這個檔案里
cat -b textfile1 textfile2 >> textfile3 把 textfile1 和 textfile2 的檔案內容加上行號(空白行不加)之后將內容附加到 textfile3 里。
范例:
把 textfile1 的檔案內容加上行號后輸入 textfile2 這個檔案里
cat -n textfile1 > textfile2
把 textfile1 和 textfile2 的檔案內容加上行號(空白行不加)之后將內容附加到 textfile3 里。
cat -b textfile1 textfile2 >> textfile3
cat /dev/null > /etc/test.txt 此為清空/etc/test.txt檔案內容
cat 也可以用來制作 image file。例如要制作軟碟的 image file,將軟碟放好后打
cat /dev/fd0 > OUTFILE
相反的,如果想把 image file 寫到軟碟,請打
cat IMG_FILE > /dev/fd0
注:
1. OUTFILE 指輸出的 image 檔名。
2. IMG_FILE 指 image file。
3. 若從 image file 寫回 device 時,device 容量需與相當。
4. 通常用在制作開機磁片。
轉載于:https://www.cnblogs.com/wllyy189/archive/2008/06/05/1214450.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的linux cat 命令详解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 骗子公司驾到
- 下一篇: “SQL Server does not