cat命令

打开linux系统的终端窗口,输入man cat ,看如下如下图的命令解说;

``` CAT(1) User Commands CAT(1)

NAME cat - concatenate files and print on the standard output

SYNOPSIS cat [OPTION]... [FILE]...

DESCRIPTION Concatenate FILE(s), or standard input, to standard output.

   -A, --show-all
          equivalent to -vET

   -b, --number-nonblank
          number nonempty output lines

   -e     equivalent to -vE

   -E, --show-ends
          display $ at end of each line

   -n, --number
          number all output lines

   -s, --squeeze-blank
          suppress repeated empty output lines

   -t     equivalent to -vT

   -T, --show-tabs
          display TAB characters as ^I

   -u     (ignored)

   -v, --show-nonprinting
          use ^ and M- notation, except for LFD and TAB

   --help display this help and exit

   --version
          output version information and exit

   With no FILE, or when FILE is -, read standard input.

EXAMPLES cat f - g Output f’s contents, then standard input, then g’s contents.

   cat    Copy standard input to standard output.

AUTHOR Written by Torbjorn Granlund and Richard M. Stallman.

REPORTING BUGS Report cat bugs to [email protected] GNU coreutils home page: http://www.gnu.org/software/coreutils/ General help using GNU software: http://www.gnu.org/gethelp/ Report cat translation bugs to http://translationproject.org/team/

COPYRIGHT Copyright © 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

SEE ALSO The full documentation for cat is maintained as a Texinfo manual. If the info and cat programs are properly installed at your site, the command

          info coreutils 'cat invocation'

   should give you access to the complete manual.

GNU coreutils 8.4 October 2014 CAT(1)

          ```
    解说cat命令的说明
    1、在控制台显示和打印文件
       查看文件内容,如下图
       ![](Screen Shot 2016-08-20 at 08.08.22.png)

      1.1 cat -b
     ``` [[email protected] ~]# cat -b a
         1  row1  value1
         2  row2  value2
         3  row3  value3


         4  row4  value4

         5  row5  value5



         6  row6  value6 
        1.2 cat -e 显示文件的换行符号
           ```[[email protected] ~]# cat -e a
            row1  value1$
            row2  value2$
            row3  value3$
            $
            $
            row4  value4$
            $
            row5  value5$
            $
            $
            $
            row6  value6$
   1.3 cat -E 同 e参数
       [[email protected] ~]# cat -E a
      ``` row1  value1$
          row2  value2$
          row3  value3$
          $
          $
          row4  value4$
          $
          row5  value5$
          $
          $
          $
          row6  value6$     ```

    1.4 cat -n  显示行号 
    ```  [[email protected] ~]# cat -n a
         1  row1  value1
         2  row2  value2
         3  row3  value3
         4
         5
         6  row4  value4
         7
         8  row5  value5
         9
        10
        11
        12  row6  value6 ```

   1.5 cat -s 连续多行空行,只显示一行
   ```[[email protected] ~]# cat -s -n a
       1  row1  value1
       2  row2  value2
       3  row3  value3
       4
       5  row4  value4
       6
       7  row5  value5
       8
       9  row6  value6```

   1.6 cat -T 显示tab为^I

    ```     
    [[email protected] ~]# cat b
    a       b       c
    d       e       f
    [[email protected] ~]# cat -T b
    a^Ib^Ic
    d^Ie^If
    ```

    1.7 cat -t 显示同1.6  
    1.8 cat -v 对dos和unix的回车换行显示
    ```
    [[email protected] ~]# cat qianke.txt 
    9195791
    82551513
    52061013
    [[email protected] ~]# cat -v qianke.txt 
    9195791^M
    82551513^M
    52061013^M 
    ```

   2 cat file1 file2 表示合并文件,但是最好合并不要太大的文件,原因太大的文件,会占用大量的内存

    ```       
    [[email protected] ~]# cat -n -ev qianke.txt a 
     1  9195791^M$
     2  82551513^M$
     3  52061013^M$
     4  row1  value1$
     5  row2  value2$
     6  row3  value3$
     7  $
     8  $
     9  row4  value4$
    10  $
    11  row5  value5$
    12  $
    13  $
    14  $
    15  row6  value6$
   ```

results matching ""

    No results matching ""