Transferred from: http://www.cnblogs.com/peida/archive/2012/11/02/2750588.html
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. The usage of less is more resilient than more. In more, we have no way to turn front, can only look back, but if use less, you can use [PageUp] [PageDown] and other key functions to go to look at the file, more easily used to view the contents of a file! In addition, in less you can have more search function, not only to search down, but also to search upward.
1. Command format:
Less [parameter] file
2. Command function:
Less is similar to more, but you can browse files at will with less, and more can only move forward, but not backwards, and no will load the entire file before viewing it.
3. Command parameters:
-B < buffer size > Set buffer size
-e When the file display is finished, automatically leave
-F forcing special files to be opened, such as peripheral code, directories, and binaries
-G only flags the last keyword searched
-I ignores case when searching
-m shows a percentage similar to the more command
-N Displays the line number of each line
-o < file name > save less output in the specified file
-Q does not use warning tones
-S displays a row of continuous empty behavior
-S line too long will be out of the partial discard
-X < number > Displays the "tab" key as a specified number space
/string: Search down the function of "string"
String: The ability to search up "string"
N: Repeat the previous search (with/or?). About
N: Reverse repeats the previous search (and/or?) About
b Turn back one page
D Turn back half a page
H Display Help interface
Q Exit less command
U scroll forward Half page
Y Scrolls forward one line
SPACEBAR Scrolls one line
Enter key to scroll one page
[PageDown]: Flip one PAGE Down
[PageUp]: Flip one page Up
4. Usage examples:
Example 1: Viewing a file
Command:
Less Log2013.log
Output:
Instance 2:ps viewing process information and displaying it via less paging
Command:
Ps-ef |less
Output:
Example 3: Viewing the history of a command using records and displaying them via less paging
Command:
History | Less
Output:
[Email protected] test]# history | Less
Scp-r tomcat6.0.32 [Email protected]:/opt/soft
CD.
Scp-r Web [Email protected]:/opt/
CD Soft
+ ls
Scp-r jdk1.6.0_16/[Email protected]:/opt/soft
Clear
Vim/etc/profile
Vim/etc/profile
CD tomcat6.0.32/bin/
ls
/shutdown.sh.
/startup.sh.
Vim startup.sh
ls
Panax Notoginseng Echo $JAVA _home
Java
All-in LS
Max LS
All clear
Cd/opt
ls
apache-tomcat-6.0.32.tar.gz CP soft/
ls
Rm-f apache-tomcat-6.0.32.tar.gz
ls
CD Soft
% ls
Tar-vzf apache-tomcat-6.0.32.tar.gz
Wuyi Tar-vzfx apache-tomcat-6.0.32.tar.gz
TAR-ZXVF apache-tomcat-6.0.32.tar.gz
ls
apache-tomcat-6.0.32 CD
ls
CD.
MV apache-tomcat-6.0.32 tomcat6.0.32
(+) LS
tomcat6.0.32/CD
ls
Example 5: Browse multiple Files
Command:
Less Log2013.log Log2014.log
Output:
Description
Input: N, switch to Log2014.log
Enter: p, switch to Log2013.log
5. Additional Notes
1. Full Screen navigation
CTRL + F-Move forward one screen
CTRL + B-Move backward one screen
CTRL + D-Move forward half screen
CTRL + U-Move backward half screen
2. Single-line navigation
J-Move one line forward
K-Move backward one line
3. Other navigation
G-Move to the last line
G-Move to the first line
Q/zz-Exit less command
4. Other useful commands
V-Edit the current file using the configured editor
H-Show help documentation for less
&pattern-Displays only the lines of the matching pattern, not the entire file
5. Tag Navigation
When you use less to view large files, you can mark them in any one place, and you can navigate to the text location labeled with a specific tag by command:
Ma-Use A to mark the current position of the text
' A-navigate to mark a
[Turn]linux's less command