Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the more command in Linux

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to use more commands in Linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use more commands in Linux" this article.

What does more do?

More is a command for paging and displaying large text files, which is built into various Linux distributions by default.

How to use more

Using the more command, simply type:

$more file_name

For example, if we want to check the log file syslog in the / var/log directory, just type:

$more / var/log/syslog

Then we can see a prompt in the lower left corner of the screen telling us that the current display ratio is 0%. The file looks quite large, so the * page is 0% of the total number of pages. Use the spacebar to scroll down the page, and then you can see that the percentage of prompts will increase.

Limit the number of rows displayed per page

When you execute the more command, it takes up all the space in your terminal window for display. But you can use the parameter-number to limit the number of rows displayed per page.

For example, if you want to limit the display of 12 lines per page, you can use the following command:

$more-12 / var/log/syslog

Now, you will see that only 12 lines are displayed on each page, and after pressing the spacebar, the page will be turned to show the next 12 lines.

Display user message

We know that the more command prompts for the percentage of current content in the lower-left corner of the display area. For a person who uses the more command * *, he or she may want to know how to scroll down the page. To avoid this, we can add the-d parameter during execution, so that an additional line of user information will be displayed. "[press the spacebar to continue,'Q' launch.]"

If the user presses a key other than 'space' or'Q', more displays a line of help "[press the'h' key to see the prompt.]"

If you press the h key, a help message is displayed:

An interesting instruction is the b button, which allows you to go back to the previous page. In other words, the b button allows you to turn the page forward.

You can pass through the upper left corner. The first page of information to confirm that the current display is the previous page.

No scrolling

Instead of scrolling the page with the parameter-c more command, it clears the previous content and replaces it with the content of the next page. With-c option, more will not scroll the page. It will clear the previous page and put the next page or lines there.

$more-10-c lynis.log

If you press the Spacebar, the next page will still have the same size.

Ignore extra blank lines

Use the parameter-s to ignore extra blank lines. Here is an example:

When we increase the parameter-s:

$more-s doc_30.txt

Find string

If your log file is very large, it is not so easy to find the string you want in it. The search function of the more command can help you. The parameter + / string can be used to search for strings, and the keywords found will be displayed on the * * line. For example, if we want to search for "dhclient" in the / var/logs/syslog file, the format of the more command:

$more + / dhclient / var/log/syslog

Then, if you want to continue searching for the next one in the file, all you have to do is press the / button, followed by the relevant keyword dhclient.

Display starts with the specified line

You can also specify the lines to start with by parameter + number. For example, we have a 15-line file:

Then we want to display the contents of the file from line 5, and the command will look like this:

$more + 5 doc_30.txt

Can I display binaries?

The answer is no. The more command prompts for such information, such as:

The above is all the contents of the article "how to use more commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report