Common Linux commands (9) and common linux commands

Source: Internet
Author: User

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!



Related Article

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.