Linux commands Daquan (4)

Source: Internet
Author: User

Some files on Windows we want to see the content, as long as there is a corresponding file of the viewing software, directly open can be seen, such as word files.

On Linux, you can do this with some commands. The functions of these commands are mainly used to display the contents of the current file, one by one.

1.cat

The cat command is used to print the contents of the current file directly to the screen.

Go back to root by the CD command (if followed by the ~ this symbol, ls see install.log, etc., on the right,),

LS to see what files are in the root directory, cat followed the file to display the content, enter the print file contents to the screen.


Summary: The command displays the file content if it is too large, the screen is not displayed, only a portion of the display, mainly for the display of small content file content.

2.more

Because cat can only display parts of large files, or small file content, in order to be able to see the entire contents of the file, you have to use the more command, as the name implies, is to show more content meaning.

Summary: Enter to see the contents of the file the last line shows--more--(3%), indicating that this position is the file content of 3%, which is a approximate value,

To see more information, press ENTER to see more. If you want to exit, CTRL + C shortcut exits the current file content view.

Of course, you may want to use PG up (upper) or PG Dn (bottom) shortcut keys to page up and down, like the book, but you find powerless, can only a meal press ENTER down to see,

If you want to go back, you can only drag the scroll bar to swipe to view.

3.less

More can see more content, but can not use up and down also page view, is a pity, let us use less to make up for regrets!

File contents:

Now it is possible to use the upper and lower keys or PG up or PG DN key for paging, although the ability to view the page, but do not know how to quit Ah,

The way is people think, the Linux command designed for us, by pressing the Q key to exit the file content view, is not solve your problem.

4.head and tail

Man's desires are not satisfied, good desires make a man, bad desires ruin a man. We have cat view file contents, though not fully,

But make use of Bai, in order to solve the problem to a more, there is a more can see all the file content, but can not use up and down page, in order to

Solve up and down pagination, look convenient, design the less command. Look at the file content to see the problem is solved, but people still feel imperfect,

If I just want to see the beginning and end of this article quickly, what's the whole story?

As long as there is a reasonable demand for the market, the product will naturally present, in order to meet the curiosity of the baby and extreme customers, designed the head and tail command to see the beginning and end of the article, the default is to display 10 lines of content.

File content first 10 lines head:


File content last 10 lines tail:



Linux commands Daquan (4)

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.