Linux commands: Cat

Source: Internet
Author: User

Introduction to CAT commands:

The purpose of the cat command is to connect files or standard input and print.

commonly used to display file content, or to connect several files to display, or to read from standard input and display, often in conjunction with redirection symbols.

The TAC writes the cat back, so his function is the opposite of the cat display sequence.


1. command format:

Cat [OPTION] ... [FILE] ...

2. Command function:

There are three major features of cat:

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. Merge several files into one file: Cat file1 file2 > file


3. Command parameters:

-A,--show-all equivalent To-vet/equivalent to-vet

-B,--number-nonblank number nonempty output lines/non-null output line numbering

-e equivalent to-ve/equivalent to-ve

-E,--show-ends display $ at end of every line/displayed at the end of each row

-N,--number number all output lines

Numbering all the lines of the output, numbering the number of rows for all outputs starting from 1

-S,--squeeze-blank suppress repeated empty output lines

Blank line with more than two lines in a row

-T vs.-VT equivalence

-T,--show-tabs display TAB characters as ^i/The tab character is displayed as ^i

-U (ignored)

-V,--show-nonprinting use ^ and m-notation, except for LFD and TAB


4. usage Examples:

Example one: The Log1.log file contents and the Log2.log file contents are displayed together with the line number .

Command:

cat-n log1.log Log2.log


Example two: The file contents of the Log1.log and the Log2.log file contents are displayed together with the line number , and the blank line is not added.

Command:

Cat-b Log1.log Log2.log


Example three: Add the Log1.log file contents to the line number after the input log3.log this file

Command:cat-n log1.log > Log3.log

Example four: Using here doc to generate files

command: Cat >log4.txt <<eof

Output:

[[email protected] test] # Cat >log4.txt <<eof

> Hello

> World

> 1

> 2

> EOF


Description

Note that the Bold section, here Doc, can be used for string substitution.


Report:

TAC line reversed, reverse listed

Command:

TAC Log.txt

Description:

The TAC writes the cat back, so his function is reversed with the cat line,

The cat is continuously displayed on the screen from the first line to the last row, while the TAC is displayed on the screen in reverse from the last line to the first line!


Linux commands: 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.