The Cat____linux of Linux commands

Source: Internet
Author: User

Cat is a very magical command.

First look at the explanation in Linux:

Linux cat commands are handy for reading short pieces, and if a file is very large, it is convenient to use page commands. Let's look at the actual application of the Linux Cat command.

Usage of Linux cat commands: Viewing files with cat commands:

$ cat test.php;
$ cat-n test.php: Add line number when viewing;

Linux Cat commands can also use wildcard characters: $ cat-n *.php, all php files are displayed (in order to display)
You can also: $ cat-n test.php test1.php test2.php; The result is identical to the output of the wildcard character.

You can combine files with the Linux Cat command and the redirection operator (>):
$ cat *.php > test3.php;

If there are two test.php and test1.php files, how to merge them now. You can use the redirection operator (>>)
$ cat test.php >> test1.php, so that the test.php merged into the back of the test1.php, the integration of the attention to the order, it is not a mistake.
You can use the Cat command to create a new file and enter content directly into the file via the keyboard.
$ cat > myfile.php
Use Ctrl+d to save and exit the file after the input is complete

If the cat and grep commands are used in combination, they will be more invincible.

Look at the example below

There are 1536 lines in the Linux.config file, and imagine how scary it would be if one line of lookup Config_keys, and if you use a combination command

Cat-n Linux.config | The grep Config_keys can be positioned quickly. The-n option is to display line numbers, which you can not use.

Of course, you can also use wildcards to find use. As shown in the above example

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.