Linux Base command (TEN) Cat command

Source: Internet
Author: User
Tags log log

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]#

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.