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.
1. Command format:
Cat [Options] File
2. Command function:
There are three major features of cat:
A. Displaying the entire file at once: Cat filename
B. Create a new file and cannot edit an existing file: cat > FileName
C. Merging several files into one file: Cat file1 file2 > file
3. Command parameters:
-A,--show all is equivalent to-vet
-B,--number nonblank to non-null output line number
-e equivalent to-ve
-E,--show-ends displays at the end of each line
-N,--number all line numbers for the output, numbering the number of rows for all outputs starting from 1
-S,--squeeze Blank has two consecutive lines or more blank lines, the substitution is a row of empty lines
-T vs.-VT equivalence
-T,--show tabs displays the jump character as ^i
-U (ignored)
-V,--show nonprinting use ^ and M-references, except LFD and TAB
4. Command instance:
Example one: output log22.txt file content and add line number
Command: Cat-n log22.txt log33.txt
Example Two: merging the contents of two files and adding line numbers
Command: Cat-b log22.txt log33.txt
Description: Add line numbers to the contents of the file Log22.txt and Log33.txt and print to the screen
Example Three: add a line number to the file and enter it into another file
Command: Cat-n log22.txt > Log.log
Note: Add the file Log22.txt and enter it into Log.log.
Example four: reverse display
Command: TAC Log.txt
Description: The TAC is writing cat in turn, so his function is the opposite of cat, and cat is continuously displayed on the screen from the first line to the last line,
The TAC is then shown on the screen by the last line to the first line in reverse!
Linux common Commands (ix)-Cat