Every day a Linux command (TEN)--cat command

Source: Internet
Author: User
Tags ack

--First of all, congratulations, this is the tenth order. --why the tenth one to congratulate?  Nothing special? --because every ten into one ah!

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:

1. Display the entire file at once: Cat filename

2. Create a file from the keyboard: cat > FileName can only create new files, cannot edit existing files

3. Merge several files into one file: Cat file1 file2 > File3

3. Command parameters:

-a--show-all equivalent to-vet

-B--number-nonblank number of non-null output lines

-e equivalent to-ve

-e--show-ends display at the end of each line

-N--number the number of all rows of the output, starting from 1 for the number of rows for all outputs

-S--squeeze-blank a blank line that has more than two lines in a row and is substituted for a row

-T equivalent to-VT

-T--show-tabs to display the jump character as ^i

-U (ignored)

-V--show-nonprinting use ^ and M-references, except LFD and TAB

4. Usage examples:

Example one: The 001.log file content with the line number after input 002.log this file

Cat-n 001.log > 002.log, copy Other people's orders, the results have been no results, later found that he wrote is Cat-n 001.log 002.log, Pit dead. I have a chance to hang out after the pit.

Command decomposition: Cat-n 001.log, with line number output, > 002.log specified input

Example two: Using here doc to generate files

Output:

[email protected] ack]# cat > Log.txt <<eof

>hold

>door

>pwd=$ (PWD)

>eof

[email protected] ack]# Cat Log.txt

Hold

Door

Pwd=/root/ack

Note:

TAC (Reverse list )

Output:

[Email protected] ack]# TAC Log.txt

Pwd=/root/ack

Door

Hold

Description: The TAC is writing cat in turn, so its function is in contrast to cat, where 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.

  

Every day a Linux command (TEN)--cat command

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.