Linux Small Commands (3) Cat

Source: Internet
Author: User

Linux commands (3) Cat

Cat is viewing the contents of a file

?

Command format: Cat file

Common parameter Description:

-N or-nimber the number of rows for all outputs starting from 1.

Example:

cat/etc/passwd

?

-B or-number-nonblank and-n are similar, except that blank lines are not numbered.

Example:

cat/etc/passwd

?

?

-S or-spueeze-blank when you encounter a blank line that has more than two consecutive lines, replace the blank line with one line

?

First go to the home directory, create several files to test, and enter information

#cd ~???????????????? ------Go to the home directory

#touch yy???????????? ------Create a file named yy

#vi yy???????????? ------Edit the file yy, enter 123456789 inside

Press "ESC" key to stop editing, use "shift+:" to pop up the command bar

Input Wq Save

?

There are three major features of cat:

  1. #cd ~???????????? ------Go to the home directory

    #cat yy???????? ------Open the file you just created yy

    You can see, print out the information we entered ourselves

    ?

  2. Create a file from the keyboard, you can only create a file, you cannot edit an existing file.

    #cd ~???????????? ------Go to the home directory

    #cat > Yy1???????? ------Create the file and enter the content abc,def and use CTRL + C to cancel

    #cat yy1???????? ------using cat to view the newly created YY1

    ?

  3. Merge several files into one file

    #cat yy yy1 > Yy2???????? ------Merge and generate a new file

    #cat Yy2???????????????? ------View the new file that you just generated

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.