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

  

原文地址:https://www.cnblogs.com/daqiang/p/3016902.html