linux 中cat的用法


1.顯示文件內容 直接 cat filename

  [root@bogon cat_test]# cat file2
  this is a test of cat
  this file's name is file2

2.顯示文件內容,對非空白行編碼 cat -b filenme 

  [root@bogon cat_test]# cat -b file1    

     1  this is for test of cat

     2  this filename is file1

     3  last line

3.對於比較大的文件,可以采用 cat filename |more

4.創建文件  cat >newfilename<<EOF

   [root@bogon cat_test]# cat >file5<<EOF
    > KNOWLEDGE IS POWER

  這個例子創建了一個file5的文件,並提示要寫入的內容,直到遇到EOF(linux下面的EOF是通過ctrl+d輸入的)。

5.向已有的文件中增加內容 cat  >>existingfile<<EOF

  [root@bogon cat_test]# cat>>file5<<EOF
  > this a new content added

同樣EOF結束輸入。

6.將幾個文件聯結輸入到一個新文件 cat  filename1 filename2  >filename3

7.將幾個文件聯結追加到一個現有的文件中 cat filenam1 filename2 >>filename3

 

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM