Linux common basic Commands (CAT)

Source: Internet
Author: User

Cat command

Action: Connect multiple files and print to the screen output, or redirect to another file, or to view a single file, or multiple files.

Format:

Cat [option] [file]

1, the simplest use, directly with the file name, view the contents of the file

[Email protected]:~/linux/catls[email protected]:~/linux/catecho ' hello,my name is Ghostwu . ' > test.txt[email protected]:~/linux/catcat  test.txt hello,my name is GHOSTWU, how is it? [email protected]:~/linux/Cat

2, you can also use the following methods to write to the file or append content

[Email protected]:~/linux/catlstest.txt[email protected]:~/linux/catCat >> test.txt << EOF> This is what I added > This is the third line of content > eof[email protected]: ~/linux/catcat  test.txt hello,my name is Ghostwu. This is what I added. This is the third line of content.

Both 3,-n and-B are numbered, and-B does not number blank lines

[Email protected]:~/linux/Cat$Cattest.txt hello,my name is GHOSTWU?This is what I added. This is the third line of content [email protected]:~/linux/Cat$Cat>> Test.txt <<EOF> > >Two blank lines are added to the above>Eof[email protected]:~/linux/Cat$Cattest.txt hello,my name is GHOSTWU?This is what I added. This is the third line with two blank lines added [email protected]:~/linux/Cat$Cat-N test.txt1Hello,my name is GHOSTWU.2This is what I added.3This is the third line of content4         5         6There are two blank lines added [email protected]:~/linux/Cat$Cat-b test.txt1Hello,my name is GHOSTWU.2This is what I added.3This is the third line of content4There are two blank lines added [email protected]:~/linux/Cat$

4,-E Displays the dollar sign at the end of each line

[Email protected]:~/linux/catcat -E test.txt hello,my name is GHOSTWU. $ This is what I added $ this is the third line of content $$$ added two blank lines above

5,-s: Put more than two consecutive empty lines into a

[Email protected]:~/linux/Cat$Cat-N test.txt1Hello,my name is GHOSTWU.2This is what I added.3This is the third line of content4         5         6         7         8Two blank lines are added to the above9        Tena blank line is added to the above [email protected]:~/linux/Cat$Cat-NS Test.txt1Hello,my name is GHOSTWU.2This is what I added.3This is the third line of content4         5Two blank lines are added to the above6         7A blank line is added to the above

6. Delete file contents using/dev/null

[Email protected]:~/linux/catcat  test.txt hello,my name is GHOSTWU. This is what I added. This is the third line with two blank lines added to the line [email protected]:~/linux/catcat /dev/null > test.txt[email protected]:~/linux/catCat

7, using redirection to write content

[Email protected]:~/linux/cat cat test.txt [email protected]:~/linux/catCat > test.txtthis is GHOSTWU what is you[email protected]:~/linux/catcat  test.txt This is ghostwuhow is

Content input completed, with Ctrl+d or CTRL + C interrupt input

8, display multiple file contents

[Email protected]:~/linux/catcat > abc.txtthis is abc.txt[email protected]:~/linux/ Cat Cat Test.txt abc.txt This is ghostwuhow be Youthis is Abc.txt

Linux common basic Commands (CAT)

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.