cat
cat command uses the connection or the standard input file and print. This command is used to display the contents of a file or several files together show the connection, or read from the standard input and display, it is often used in conjunction with a redirection symbol
Note: When the file is large, the text on the screen quickly flashed (scroll), users often can not see what is displayed. Thus, more generally split-screen display command and the like. To control the scrolling, you can press Ctrl + S to stop scrolling; press Ctrl + Q key recovery scrolling. Press Ctrl + C (interrupt) key to terminate execution of the command, and returns prompt Shell
format
cat [options] [parameters]
Parameter options
parameter | Remark |
---|---|
-A | --show-all equivalent -vET |
-b | --number-nonblank number nonempty output lines |
-e | Equivalent to -vE |
-E | --show-ends display $ at the end of each line |
-n | --number numbers for all lines output by 1 start number for the number of lines for all outputs |
-s | --squeeze-blank with more than two successive blank lines, with a blank line to line substitution |
-t | And -vT equivalent |
-T | --show-tabs the tab character is displayed as ^ I |
-v, | --show-nonprinting use ^ and M- references, in addition to the LFD and TAB |
Examples
At the same time display the contents of files ml and m2
Command: CAT myfile1 myfile2
[root@VM_0_9_centos ~]# cat myFile1
my name is wuzhazha
i am 25 years old
[root@VM_0_9_centos ~]# cat myFile2
my name is zhangbaobao
i am 28 years old
[root@VM_0_9_centos ~]# cat myFile1 myFile2
my name is wuzhazha
i am 25 years old
my name is zhangbaobao
i am 28 years old
[root@VM_0_9_centos ~]#
The file myFile1 and myFile2 merged into the file in myFile
Command: CAT M1 M2> File
[root@VM_0_9_centos ~]# cat myFile1 myFile2 > myFile
[root@VM_0_9_centos ~]# cat myFile
my name is wuzhazha
i am 25 years old
my name is zhangbaobao
i am 28 years old
[root@VM_0_9_centos ~]#
MyFile3 the input file with line numbers after the file content myFile1
Command: CAT myfile1 -n> myfile3
[root@VM_0_9_centos ~]# cat -n myFile2 > myFile3
[root@VM_0_9_centos ~]# cat myFile3
1 my name is zhangbaobao
2 i am 28 years old
The file myFile1 and myFile2 content after the merger appended to myFile4
Command: CAT myfile1 myfile2 >> myfile4
[root@VM_0_9_centos ~]# cat myFile4
fuck my life!!!!
[root@VM_0_9_centos ~]# cat myFile1 myFile2 >> myFile4
[root@VM_0_9_centos ~]# cat myFile4
fuck my life!!!!
my name is wuzhazha
i am 25 years old
my name is zhangbaobao
i am 28 years old