In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "what is the difference between less and more in linux". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
Difference: 1, less can press the up and down arrow keys to display the upper and lower content, and more can not control the display through the up and down arrow keys;2, less does not have to read the entire file, loading speed is faster than more;3, less after exiting the shell will not leave just displayed content, and more after exiting will leave just displayed content on the shell.
This tutorial operates on CentOS 6 and Dell G3 computers.
Linux more and less commands
the more command
The more command displays the contents of a text file page by page. The user can read the contents page by page. The basic format of this command is as follows:
[root@localhost ~]# more [options] filename
The more command is relatively simple, generally without any options, for the options listed in Table 1, readers only need to see the recognition.
Table 1 more Command options and their meanings Option meanings-f When calculating the number of lines, use the actual number of lines, not the number of lines after the automatic wrap. - pInstead of scrolling through each page, clear the screen before displaying the content. - c is similar to-p except that the content is displayed first and then other old data is cleared. - s When there are more than two consecutive blank lines, replace them with one blank line. - u does not display bottom quotes (varies depending on the terminal specified by the environment variable $TERM).+ n Displays the file content starting at line n, where n represents a number. - n Number of rows displayed at a time, n stands for number.
less command
The less command is very similar to the more command, which is used to browse the contents of a text file. The difference is that when using the more command to browse the contents of the file, you can only keep looking backwards, while using the less command to browse, you can look backwards or forward.
Not only that, but in order for users to browse text content, the less command also provides the following functions:
Use the cursor keys to scroll back and forth (left and back) in a text file;
Browse files with line numbers or percentages as bookmarks;
Provide more user-friendly search, highlighting and other operations;
Keyboard operation compatible with commonly used word processing programs (such as Vim, Emacs);
The less command does not exit when reading to the end of the file;
The message prompt at the bottom of the screen is easier to control and provides more information.
The basic format of the less command is as follows:
[root@localhost ~]# less [options] filename
The options available for this command and their respective meanings are shown in Table 1.
Table 1. Less command options and their meanings Option meanings-N Displays the line number of each row. - If the S line is too long, the excess will be discarded. - e Leave automatically when the file is displayed. - g marks only the last key found. - Q Do not use warning tones. - i Ignore case when searching. - m Displays the percentage of commands like more. - f Forces special files to open, such as peripheral codes, directories, and binary files. - s Display a row of consecutive empty rows. - b Sets the buffer size. - o Save less output to specified file. - x Displays the Tab key as a specified numeric space.
Difference between more and less:
1, less can press the keyboard up and down arrow keys to display up and down content, while more can not be displayed through the up and down arrow keys
Less doesn't have to read the entire file, it loads faster than more.
3, less exit shell will not leave just displayed content, and more exit will leave just displayed content on the shell
At the end of the document, less does not quit, but more does.
Less can be bookmarked with line numbers or percentages, but more cannot.
6, compared to more, less provides more friendly search, highlighting and other operations
Extended knowledge: Linux less command common examples
view the file contents
syntax
less file
case
We use the less command to view the contents of the/etc/vimrc file, as follows:
less /etc/vimrc
After running, the terminal output is as follows:
We see that we used the less command to view the file content, and now we can use the above interactive command to operate on the text, for example, we press the Enter key, we can move down a line, after running, the terminal output is as follows:
At the same time, we can also use the space bar to move down one page. After running, the terminal output is as follows:
That is, we used the less command to split the screen and view the file contents.
View file contents and display line numbers
syntax
less -N file
case
We use the less command to view the contents of the/etc/vimrc file and display the line number, as follows:
less -N /etc/vimrc
After running, the terminal output is as follows:
This time, we used the less command to view the file contents and display the line numbers.
less command string search
syntax
/str
case
We use the less command to view the contents of the/etc/vimrc file, as follows:
less /etc/vimrc
After running, the terminal output is as follows:
Now we can start searching for strings using the/str form, as shown below:
Now, we press Enter to start the search, as shown below:
We see that all matching strings are highlighted, i.e. we searched for the string we specified using the/str form, and we can also match the next string using n and the previous string using N.
"What is the difference between less and more in Linux?" is introduced here. Thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.