If you are used to working on a Linux system, you will surely find a large number of text files in the Linux world. Configuration and log files are usually in text format. These files usually have a long content and cannot be displayed in one screen. So when dealing with this kind of files, we need to display them in pages. Now we can use itmoreCommand.
What’s more for
More is a command used to display large text files in pages. It is built into each Linux distribution by default.
How to use more
With the more command, just type:
$ more file_name
For example, to check the log file syslog in the / var / log directory, just type:
$ more /var/log/syslog
And then we can seeThere is a prompt in the lower left corner of the screen, which tells us that the current display scale is 0%. It looks like this file is quite large, so the first page is 0% of the total number of pages. Use the space bar to scroll down the page, and then you can see that the percentage of prompts increases.
Limit the number of lines displayed per page
When executing the more command, it will occupy all the space of your terminal window for display. But you can use the parameters– DigitalTo limit the number of rows displayed per page.
For example, you want every pageLimit display to 12 lines, you can use the following command:
$ more -12 /var/log/syslog
Now, you will see that only 12 lines are displayed per page. After pressing the space bar, the next 12 lines will be displayed.
Display user message
As we know, the more command prompts the lower left corner of the display area for the percentage of the current content. For the first time using the more command, he or she may want to know how to turn down the page. To avoid this, we can add-dParameter, which will display an additional line of user information[Press the space bar to continue, ‘Q’ launch]”
If the user presses‘space’ or ‘Q‘Other buttons, more will display a line of help information“[press the ‘H’ key to see the prompt. ]
If you press the H key, a help message is displayed:
An interesting instruction isbButton,B button allows youGo back to the previous page. In other words, the B button allowsFlip pages forward。
You can go through theThe first 1 PagesMessage to confirm that the previous page is currently displayed.
Pass parameters-c, the more command does not scroll the page, but directly 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 space bar, the next page will still have the same size.
Ignore extra blank lines
Using parameters-sTo ignore the extra blank lines, here is an example:
When we add parameters-sLater:
$ more -s doc_30.txt
If your log file is very large, it’s not so easy to find the string you want. The find function of the more command can help you through the parameters+/stringIt can be used to search for strings, and the keywords found will be displayed in the first line. For example, we have to/var/logs/syslogSearch in file“dhclient”, 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, just press/ button, followed by the keyword dhclient.
Display from specified line
You can also use parameters+ numberFor example, we have a 15 line file:
Then we want to display the contents of this file from line 5. The command looks like this:
$ more +5 doc_30.txt
Can binaries be displayed?
The answer is noThe. More command prompts for information such as:
More is a basic tool for viewing text files. It cannot be used to display binary files. Usually, we can use the commandman moreperhapsmore –helpFor more information on how to use more.