Less will not load the entire file before viewing. Try to use less and VI to open a large file, and you will see the difference in speed between them.
In less, the navigation command is similar to VI. This article will introduce some navigation commands and other tips for using less.
1 search
After opening a file with the command less file-name, you can search for the file in the following method. The matching part of the entire text is highlighted during the search.
Forward search
/-Search in one mode and locate the next matched text
N-search for the next matched text
N-search for the previous matched text
Backward Search
? -Search in mode and locate the previous matched text
N-search for the next matched text
N-search for the previous matched text
2 full screen navigation
CTRL + F-move the screen forward
CTRL + B-move one screen backward
CTRL + D-move the half screen forward
CTRL + U-move the half screen backward
3 single-line navigation
J-move a row forward
K-move a row backward
4 other navigation
G-Move to the last row
G-Move to the first line
Q/ZZ-exit the less command
5. other useful commands
V-use the configuration editor to edit the current file
H-show the less help document
& Pattern-only show matching mode rows, not the entire file
6. Mark navigation
When you use less to view large files, you can mark any location. You can use commands to navigate to the text location marked with a specific tag.
Ma-mark the current position of the text with
'A-Navigate to mark
7. Browse multiple files
Method 1: Pass multiple parameters to less to browse multiple files.
Less file1 file2
Method 2: when you are browsing a file, use: E to open another file.
Less file1
: E file2
When opening multiple files, use the following command to switch between multiple files:
: N-browse the next file
: P-browse previous file