The purpose of the cat command is to connect files or standard input and print. This command is often used to display the contents of a file, or to connect several files to a display, or to read content from standard input and display it, often in conjunction with a redirection symbol.
1. Command format:
Cat [Options] [file] ...
2. Command function:
Cat has three main functions:
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. Merging several files into one file: Cat file1 file2 > file
3. Command parameters:
-A,--show-all equivalent to-vet
-B,--number-nonblank for non-null output line numbering
-e equivalent to-ve
-E,--show-ends displays $ at end of each line
-N,--number all row numbers for the output, numbering the number of rows for all outputs starting with 1
-S,--squeeze-blank has two consecutive rows of blank lines, the substitution of a line of blank lines
-T and-VT equivalence
-T,--show-tabs displays the ^i character as a
-U (ignored)
-V,--show-nonprinting use ^ and M references, except LFD and TAB
4. Use instance:
Example one: The Log2012.log file content with the line number after the input log2013.log this file
Command:
Cat-n Log2012.log Log2013.log
Output:
[Root@localhost test]# Cat Log2012.log
2012-01
2012-02
======[root@localhost test]# Cat Log2013.log
2013-01
2013-02
2013-03
======[root@localhost test]# cat-n Log2012.log log2013.log
1 2012-01
2 2012-02
3
4
5 = = =
6 2013-01
7 2013-02
8
9
10 2013-03
One ======[root@localhost test]#
Description
Example two: Append the contents of Log2012.log and Log2013.log to Log.log after adding line numbers (blank lines).
Command:
Cat-b Log2012.log Log2013.log Log.log
Output:
[Root@localhost test]# cat-b log2012.log log2013.log log.log
1 2012-01
2 2012-02
3 = = =
4 2013-01
5 2013-02
6 2013-03
7 = = = [Root@localhost test]#