Summary of the usage of the Linux command less command

  

The less command in Linux is mainly used to browse the contents of the file, similar to the usage of the more command. Unlike the more command, the less command can be scrolled back and viewed. Partly, let's take a look at the specific usage of the less command along with the small series.

The usage of less is more flexible than more. At more time, we have no way to turn to the front, only to look at the back, but if you use less, you can use the function of [pageup] [pagedown] and other keys to go back and look at the file, easier to use View the contents of a file! In addition, you can have more search functions in less, not only can search down, but also up.

1. Command format:

less [parameters] File

2. Command function:

less Similar to more, but use less to browse files at will, and more can only move forward, but not backwards, and less does not load the entire file before viewing.

3. Command parameters:

-b "Buffer size" Set the size of the buffer

-e When the file is displayed, leave

-f to force the special file to open. For example, peripheral code, directory, and binary files

-g only flags the last searched keyword

-i ignores case when searching

-m displays similar commands Percentage

-N Display the line number of each line

-o "File name" Save the contents of the less output in the specified file

-Q Do not use warnings Sound

-s Shows a line of continuous empty behavior

-S Lines are discarded for a long time.

-x "Number" Shows the "tab"" button as a rule Number spaces

/string: Search for the function of "string"

? String: Search for the function of "String" in string

n: Repeat the previous search (related to /or ?)

N: Repeat the previous search in reverse (with /or ? Related)

b Flip back one page

d Flip back half a page

h Display help screen

Q Exit the less command

u Scrolling half a page forward

y Scrolling one line forward

Spacebar scrolling one line

Enter key to scroll one page

[pagedown ]: Scroll down one page

[pageup]: Scroll up one page

4. Example:

Example 1: Check the file

command:

less log2013.log

Output:

Examples 2: ps view process information and display through less page

Command:

ps -ef | Less

Output:
Previous12Next Total 2 Pages

Copyright © Windows knowledge All Rights Reserved