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

25 fresh useful icon sets for download abroad

1. E-Commerce Icons 2. Icon Sweets 2 3. Mobile Ph...

Teach you how to use vscode to build a react-native development environment

question The code has no prompt: Many non-front-e...

Linux uses iftop to monitor network card traffic in real time

Linux uses iftop to monitor the traffic of the ne...

One-click installation of MySQL 5.7 and password policy modification method

1. One-click installation of Mysql script [root@u...

Vite introduces the implementation of virtual files

Table of contents background Importing virtual fi...

Today I will share some rare but useful JS techniques

1. Back button Use history.back() to create a bro...

Solution to mysql server 5.5 connection failure

The solution to the problem that mysql cannot be ...

A practical record of restoring a MySQL Slave library

Description of the situation: Today, I logged int...

WeChat applet scroll-view realizes left-right linkage effect

WeChat applet uses scroll-view to achieve left-ri...

MySQL 8.0.15 installation graphic tutorial and database basics

MySQL software installation and database basics a...

How much data can be stored in a MySQL table?

Programmers must deal with MySQL a lot, and it ca...

MySQL UNION operator basic knowledge points

MySQL UNION Operator This tutorial introduces the...