Linux less command

Source: Internet
Author: User

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

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.