Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of less command in linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "the usage of less command in linux". In daily operation, I believe many people have doubts about the usage of less command in linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "the usage of less command in linux". Next, please follow the editor to study!

1. Command format:

Less [parameters] file

2. Command function:

Less is similar to more, but you can browse files at will with less, while more can only move forward, but not backward, and less does not load the entire file before viewing it.

3. Command parameters:

-b sets the size of the buffer

-e automatically leave when the file is displayed

-f force the opening of special files, such as peripheral codes, directories, and binaries

-g marks only the last keyword searched

-I ignore the case of the search

-m displays the percentage similar to the more command

-N displays the line number of each line

-o Save the less output in the specified file

-Q does not use warning tones

-s displays a row of continuous empty behavior

-S line will be discarded if it takes too long

-x displays the "tab" key as a specified number space

/ string: the ability to search down for "string"

? Strings: the ability to search up for "strings"

N: repeat the previous search (and / or? Related)

N: reverse repeat the previous search (and / or? Related)

B turn back one page

D turn back half a page

H displays the help interface

Q exits the less command

U scroll forward half a page

Y scroll forward one line

The spacebar scrolls one line

Press enter to scroll one page

[pagedown]: turn a page down

[pageup]: turn a page up

4. Use an example:

Example 1: view files

Command:

Less log2013.log

Output:

The instance 2:ps views the process information and displays it through less paging

Command:

Ps-ef | less

Output:

Example 3: view the command history and display it through less paging

Command:

History | less

Output:

The code is as follows:

[root@localhost test] # history | less

Scp-r tomcat6.0.32 root@192.168.120.203:/opt/soft

Cd..

Scp-r web root@192.168.120.203:/opt/

Cd soft

Ls

Scp-r jdk1.6.0_16/ root@192.168.120.203:/opt/soft

Clear

Vim / etc/profile

Vim / etc/profile

Cd tomcat6.0.32/bin/

Ls

. / shutdown.sh

. / startup.sh

Vim startup.sh

Ls

Echo $JAVA_HOME

Java

Ls

Ls

Clear

Cd / opt

Ls

Cp apache-tomcat-6.0.32.tar.gz soft/

Ls

Rm-f apache-tomcat-6.0.32.tar.gz

Ls

Cd soft

Ls

Tar-vzf apache-tomcat-6.0.32.tar.gz

Tar-vzfx apache-tomcat-6.0.32.tar.gz

Tar-zxvf apache-tomcat-6.0.32.tar.gz

Ls

Cd apache-tomcat-6.0.32

Ls

Cd..

Mv apache-tomcat-6.0.32 tomcat6.0.32

Ls

Cd tomcat6.0.32/

Ls

Example 4: browse multiple files

Command:

Less log2013.log log2014.log

Output:

Description:

After entering: n, switch to log2014.log

After entering: P, switch to log2013.log

5. Additional remarks

1. Full screen navigation

Ctrl + F-move forward one screen

Ctrl + B-move backwards one screen

Ctrl + D-move half screen forward

Ctrl + U-move half screen backward

two。 One-way navigation

J-move forward one line

K-move backward one line

3. Other navigation

G-move to the last line

G-move to the first line

Q / ZZ-exits the less command

4. Other useful commands

V-use the configured editor to edit the current file

H-displays help documentation for less

& pattern-displays only the lines that match the pattern, not the entire file

5. Tag navigation

When viewing a large file using less, you can mark it anywhere, and you can navigate to a text location marked with a specific tag through the command:

Ma-use a to mark the current position of the text

'a-navigate to mark a

At this point, the study of "the use of the less command in linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report