Detailed explanation of Linux less command examples

Detailed explanation of Linux less command examples

less file name View File
less file name | grep -n search content Filter and display according to content and display line numbers
less + line number g file name View the file and locate a line
d Scroll down
u Page up
g Jump to first line
G Jump to bottom
? Find content Look up
/ Search content Find down
n Next
N Previous
q Exit less command

Here are some specific examples:

1. Open the file less catalina.out

2. View the file and display the line number less -N catalina.out

3. Locate a line (here, line 10) less +10g catalina.out

This is the 10th row.

You can verify by displaying the line number, less -N +10g catalina.out

4. After opening the file, search for content in it

Find the timestamp 2018-07-06 15:24:00,025 and enter the command

/2018-07-06 15:24:00,025

The found content will be automatically highlighted, followed by n for the next one and N for the previous one.

Same for searching upwards? Find content

Finally, don't forget to exit the less command with q

This is the end of this article about the detailed explanation of the linux less command examples. For more related linux less command details, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

<<:  The problem of Vue+tsx using slot is not replaced

>>:  Solution to mysql ERROR 1045 (28000) problem

Recommend

MySQL inspection script (must read)

As shown below: #!/usr/bin/env python3.5 import p...

Detailed explanation of how to detect and prevent JavaScript infinite loops

Table of contents Preface Fix infinite loop in fo...

Embed player in web page embed element autostart false invalid

Recently, I encountered the need to embed a player...

Do you know how to use Vue to take screenshots of web pages?

Table of contents 1. Install html2Canvas 2. Intro...

Detailed explanation of object literals in JS

Table of contents Preface 1. Set the prototype on...

In-depth understanding of the use of CSS clear:both

clear:both is used to清除浮動This is the impression I...

Flex layout realizes the layout mode of upper and lower fixed and middle sliding

This article mainly introduces the layout method ...

A brief discussion on the perfect adaptation solution for Vue mobile terminal

Preface: Based on a recent medical mobile project...

Detailed explanation of flex layout in CSS

Flex layout is also called elastic layout. Any co...

Summary of some related operations of Linux scheduled tasks

I have searched various major websites and tested...

jQuery implements article collapse and expansion functions

This article example shares the specific code of ...

JavaScript implements single linked list process analysis

Preface: To store multiple elements, arrays are t...

Detailed steps to install mysql5.7.18 on Mac

1. Tools We need two tools now: MySQL server (mys...