Linux common Commands (ix)-Cat

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.