Linux commands: Cat (Common approach)
Description:
Cat is a text file viewing and linking tool. To view the contents of a file, it is simple to use cat, that is, the cat directly behind the file name, such as Cat Linuxyw.txt. The purpose of the cat command is to connect files or standard input and print. This command is commonly used to display the contents of a file, or to connect several files to display, or to read from a standard input and display it, often in conjunction with redirection symbols.
cat--help can view cat help information, such as the use of various parameters, of course, can also be viewed with the man cat, it is recommended that you get into the command do not understand the use of--help or man to view help information, develop good habits. fileName is the filename, which is the name of the file that needs to be viewed in the system.
The commands similar to this command are: TAC, Less, tail, More
1. command format:
Cat [Options] [file] ...
2. Command function:
There are three major features of cat:
1. Display the entire file at once: Cat filename
2. Create a file from the keyboard: cat > FileName can only create new files and cannot edit existing files.
3. Merge several files into one file: Cat file1 file2 > file
Special usage of 4.cat: Add multiple lines of content
Cat >> file name <<eof
Xxxxxxxxxxxxxxxxxx
Xxxxxxxxxxxxxxxxxx
Xxxxxxxxxxxxxxxxxx
EOF (this can be any character)
3. Command parameters:
parameter Description:
-a:--show-all equivalent to-vet
-b:--number-nonblank Number of non-null output lines, that is, the line number displayed before each line
- E: equivalent to-ve
- E:--show-ends displays at the end of each line
-n:--number The number of all lines of the output, that is, the line number displayed before each line
-s:--squeeze-blank does not output multiple lines of blank lines
- T: equivalent to-VT
-t:--show-tabs The jump character as ^i
-u: (ignored)
-V:--show-nonprinting uses ^ and M-references, except LFD and TAB
--help Display this help message and leave
4. Command instance:
1) cat-n filename Displays the line number of the file
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7E/6C/wKiom1b-ZFLC-TpMAAATMgtZgZI171.png "title=" Picture 1.png "alt=" Wkiom1b-zflc-tpmaaatmgtzgzi171.png "/>
2) Cat Create file or connection file
with cat when creating a file, you need to use eof end (non-mandatory eof eof on the line) If you manually use cat when you create a file, you end up pressing ctrl+d key combinations.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7E/69/wKioL1b-ZRTB9giJAAAW_2woeN0045.png "style=" float: none; "title=" Image 2.png "alt=" Wkiol1b-zrtb9gijaaaw_2woen0045.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7E/6C/wKiom1b-ZG-gitcBAAAb8x--09k887.png "style=" float: none; "title=" Image 3.png "alt=" Wkiom1b-zg-gitcbaaab8x--09k887.png "/>
in the CAT&NBSP;>&NBSP; test.txt >", >>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7E/69/wKioL1b-ZSugQ1UMAAAkHqAUffQ641.png "title=" Picture 4.png "alt=" Wkiol1b-zsugq1umaaakhqauffq641.png "/>
eof symbol, Span style= "Font-family:verdana;color:rgb (51,51,51); letter-spacing:0;font-weight:normal;font-style:normal; Font-size:14px;background:rgb (243,243,243); " >
When the first line is used <<eof When the end is also needed Span style= "Font-family:verdana;" >eof > >>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7E/6C/wKiom1b-ZJfRtfpiAAAcp4hhanE565.png "title=" Picture 5.png "alt=" Wkiom1b-zjfrtfpiaaacp4hhane565.png "/>
Linux common commands: How to use Cat