How to find the specified content of a large file in Linux

How to find the specified content of a large file in Linux

Think big and small, then redirect.

Sometimes Linux encounters very large files, and keyword searches must exceed the entire screen, making it impossible to view all the content. For example, if we want to view all logs of a certain string in a very large log file info.log, we can use cat info.log | grep '1711178968'. If too much is displayed, we can add time and line control. You can also use the '>>' command. cat info.log | grep '1711178968' >> temp.log Temporarily save the intermediate results and view the temp.log file page by page using tools such as more and less

If the log is within a certain time range, you can still intercept the log based on time:

// Capture the logs for a certain period of time sed -n '/2018-10-25 17:30:41/,/2018-10-25 21:47:02/p' root.2018-10-25.log > update.log

In the log on the 25th, extract the logs between 17:30 and 21:47.

Use the more command to view.

Then search with /${keyword}, ​​for example /1711178968, n for the next item, b for the previous item

The above method of implementing how to search for specified content in large files in Linux is all I have to share with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • How to Find the Top 10 Largest Files in Linux
  • How to find large directories and large files in Linux (recommended)
  • Linux searches for files containing specified text (linux searches for specified files)

<<:  The correct way to use MySQL indexes and detailed explanation of index principles

>>:  How to Develop a Progressive Web App (PWA)

Recommend

Detailed steps for setting up a nexus server

1. The significance of building nexus service As ...

Code to display the contents of a txt book on a web page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML ...

Tips for using DIV container fixed height in IE6 and IE7

There are many differences between IE6 and IE7 in ...

Steps to use ORM to add data in MySQL

【Foreword】 If you want to use ORM to operate data...

mysql8.0.11 winx64 manual installation and configuration tutorial

First of all, let me talk to you about my daily l...

Slot arrangement and usage analysis in Vue

The operating environment of this tutorial: Windo...

How to run top command in batch mode

top command is the best command that everyone is ...

Detailed tutorial on installing Docker on Windows

Since my local MySQL version is relatively low, I...

Summary of several submission methods of HTML forms

The most common, most commonly used and most gener...

A graphic tutorial on how to install MySQL in Windows

Abstract: This article mainly explains how to ins...

Detailed graphic tutorial on installing and uninstalling Tomcat8 on Linux

[ Linux installation of Tomcat8 ] Uninstall Tomca...

Quick understanding and example application of Vuex state machine

Table of contents 1. Quick understanding of conce...

Two ways to clear table data in MySQL and their differences

There are two ways to delete data in MySQL: Trunc...