First, operating environment

Windows 10 64-bit operating system +CentOS7+MobaX

2. Definition of Linux cat command

The cat(concatenate) command is used to connect files and print them to the standard output device.

Three, usage,

Cat [option]... [file]...

Output [file] or standard input combination to standard output.

4. Common parameters

-n or –number: number of all output lines starting from 1.

-b or –number-nonblank: similar to -n except that blank lines are not numbered.

-s or –squeeze-blank: When there are more than two consecutive blank lines, replace them with one blank line.

-v or –show-nonprinting: use ^ and M- symbols, except LFD and TAB.

-e or –show-ends: displays $at the end of each line.

– T or – show – tabs: show the TAB character for ^ |.

-a or –show-all: equivalent to -vet.

-e: equivalent to the “-ve” option.

-t: equivalent to the “-vt” option.

Five, presentations,

5.1 Prerequisites

1. Start the VM and connect it to MobaX

2. Create two files with arbitrary contents, as shown in the following figure (test11 and test22 will be modified in later instances as required by the instance) :

5.2 instance

1. View the contents of the test11 file.

cat test11
Copy the code

2. View the contents of the test11 file and add line numbers starting from 1.

Cat -n test11 or cat --numberCopy the code

3. View the contents of the test22 file and number the non-blank files starting from 1.

Cat -b test22 or cat --number-nonblankCopy the code

4. View the test22 file and replace two or more consecutive blank lines with one blank line.

Cat -s test22 or cat --squeeze-blank or NL test22Copy the code

5. Review the contents of the test22 file and append the $sign at the end.

cat -E test22
Copy the code

6. Cat can view multiple files simultaneously

cat test11 test22
Copy the code

7. Great files can be used for content pipeline operator (|) and more to turn the pages of the (using the blank space key down under more order page N key page up)

cat test11 | more
Copy the code

8. Write the two files together to a new file (note! : If the file has original content, the original content will be cleared!

cat test11 test22 > test33
Copy the code

9. Append the two files together to the new file (the original contents will not be emptied)

cat test11 >>test33
Copy the code

Never confuse > with >>!! The wrong use can bring great loss!!

Six, summarized

The paper come zhongjue shallow, and must know this to practice.

Talent and learning, clumsy text a welcome yazheng.