Linux more and less

Source: Internet
Author: User


================================more================================
More is one of our most commonly used tools, the most commonly used is to display the content of the output, and then according to the size of the window to display the page, and then can also indicate the percentage of the file;
# More/etc/profile
More syntax, parameters and commands;
More [parameter options] [file]
The parameters are as follows:
+num starting from Num line;
-num defines the screen size for NUM lines;
+/pattern starts from the first two lines of the pattern;
-C clear the screen from the top and then display;
-D Prompt Press space to continue, ' Q ' to quit. (Pressing the NULL key to continue, press the Q key to exit), disable the ringing function;
-L ignores Ctrl+l (page break) characters;
-P pages are changed by clearing the window instead of scrolling. A bit similar to the-c parameter;
-S displays consecutive empty lines as one line;
-U Remove the underline from the contents of the file
The action command to exit more is Q
more parameter application examples;
# more-dc/etc/profile Note: Display the prompt and display from the top of the terminal or console;
# more +4/etc/profile Note: Starting from the 4th line of profile;
# more-4/etc/profile Note: Display 4 rows per screen;
# more +/mail/etc/profile Note: Start with the first two lines in the profile of a MAIL word;
More action instructions;
When we look at a larger file, we use more action instructions, such as ctrl+f (or SPACEBAR) is to display a screen down, Ctrl+b is to return to the previous screen, the ENTER key can scroll down to display n rows, to pass the default is 1 rows;
We only talk about a few commonly used, and try to know it by ourselves;
Enter down n rows, need to be defined, default to 1 rows;
CTRL+F scroll down one screen;
The null key scrolls down one screen;
Ctrl+b return to the previous screen;
= Output the line number of the current line;
: F output File name and line number of the current line;
V Call VI Editor;
! command to invoke the shell and execute the command;
Q Exit More
When we look at a file, want to call VI to edit it, do not forget the V-action command, which is more convenient;
Examples of other commands used in combination with piping and more;
For example, we list a directory of files, because the content is too much, we should learn to use more to page display. This has to do with plumbing | Together, for example:
# Ls-l/etc |more
============================less================================
Less view file contents tool;
The less tool is also a tool for paging through files or other output, which is a very powerful tool for Linux to view the contents of a file, and it is a beginner, I suggest you use less. Because less content too much, we put the most commonly used to introduce;
The syntax format of less;
Less [parameter] file
Common parameters
-C refreshes the screen from top to bottom and displays the contents of the file. Instead of scrolling through the bottom to complete the refresh;
-F Force open file, binary file display, do not prompt warning;
-I ignores case when searching, unless the search string contains uppercase letters;
-I ignores case when searching, unless the search string contains lowercase letters;
-m displays the percentage of files read;
-m explicit read the file percentage, line number and total number of rows;
-N Enter the travel number in front of each line;
-P Pattern Search pattern, for example, in/etc/profile search word MAIL, use less-p mail/etc/profile
-S displays consecutive blank lines as a blank line;
-Q does not ring under the terminal;
For example: When we display the content of/etc/profile, let it display the line number;
# less-n/etc/profile
Less's action command;
After entering less, we have to learn a few actions, so that it is more convenient for us to check the contents of the file, the most should remember the command is Q, which allows less to terminate the view file exit;
Action
The ENTER key moves down one line;
Y move up one line;
The space bar scrolls down one screen;
b scroll up one screen;
D scroll down half screen;
H less's help;
U move up the half screen;
W can specify which line to start displaying, which is displayed from the next line of the specified number, for example, 6, which is displayed from line 7th;
G jumps to the first line;
G jumps to the last line;
P n% jumps to n%, such as 10%, which means that it starts at 10% of the entire file content;
/pattern searches for pattern, such as/mail, to search for mail words in a file;
V Call VI Editor;
Q Exit Less
!command Call the shell, you can run the command, such as!ls display the current column in the current directory of all files;
As far as less is concerned, there is too much content, and it is best to look for man when using it. Here is not an example;

Linux more and less

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.