- Published on
less command-paged display tool
Jonas
2 min read
When browsing the content of the text file and displaying the file with the less command, the PageUp key will turn the page up and the PageDown key will turn the page down. To exit the less program, press the Q key.
The role of less is very similar to that of more. The difference is that the less command allows the user to browse files forward or backward, while the more command can only browse forward.
Syntax: less [parameter] [file]
Command parameters:
-b | The size of the buffer |
-e | When the file display ends, it will leave automatically |
-f | Force opening of special files, such as peripheral device codes, directories, and binary files |
-g | Only mark the last keyword searched |
-i | Ignore case when searching |
-m | Show the percentage of similar more commands |
-N | Display the line number of each line |
-o | Save the content output by less in the specified file |
-Q | No warning sound |
-s | Show continuous empty rows |
-S | Display longer content in a single line without wrapping |
-x | Display TAB characters as a specified number of space characters |
Command explanation:
- b - Turn back one paged Turn half page backward
- h - Display the help interface
- Q -Â Exit the less command
- u - Scroll forward half a page
- y - scroll forward one line
- Space bar - to scroll one page
- Enter - to scroll one line
Example
check the file:[root@linuxstar ~]# less test.phpps view process information and display through less paging:
[root@linuxstar ~]# ps -ef |lessView command history usage records and display through less paging:
[root@linuxstar ~]# history | less 22 scp -r tomcat6.0.32 root@192.168.120.203:/opt/soft 23 cd .. 24 scp -r web root@192.168.120.203:/opt/ 25 cd soft …… Omit...Browse multiple files:
[root@linuxstar ~]# less log2018.log log2019.logWhen browsing a file, you can also use the :e command to open another file:
[root@linuxstar ~]# less file1 :e file2