Common Linux commands (9) and common linux commands
The cat command is used to connect files or standard input and print. This command is often used to display the file content, connect several files, or read and display the content from the standard input. It is often used with the redirection symbol.
1. Command Format:
Cat [Option] File
2. command functions:
Cat has three main functions:
A. the entire file is displayed at one time: cat filename
B. Create a new file and cannot edit the existing file: cat> filename
C. Merge several files into one file: cat file1 file2> file
3. command parameters:
-A, -- show all is equivalent to-vET.
-B, -- number nonblank indicates the number of non-empty output rows.
-E is equivalent to-vE.
-E, -- show-ends is displayed at the end of each line $
-N, -- number indicates the number of all rows output, starting from 1.
-S, -- squeeze blank has more than two rows of blank rows in a row.
-T is equivalent to-vT.
-T, -- show tabs will display the grid skip character as ^ I
-U (ignored)
-V, -- show nonprinting use ^ and M-reference, except LFD and TAB
4. Command instance:
Instance 1:Output The log22.txt file content and add the row number
Command: cat-n log22.txt log33.txt
Example 2:Merge the contents of the two files and add the row number.
Command: cat-B log22.txt log33.txt
Note: add the line numbers of the log22.txtand log33.txt files and print them to the screen.
Example 3:Add the row number of the file content and input it to another file.
Command: cat-n log22.txt> log. log
Note: add the log22.txt file with the row number and input it to log. log.
Example 4:Reverse display
Command: tac log.txt
Note: tac writes cat in turn, so its function is opposite to cat. cat is displayed on the screen consecutively from the first row to the last row,
Tac is displayed on the screen from the last line to the first line!