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

What are the commands for Linux to filter query logs

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Today, I would like to share with you what are the relevant knowledge points of Linux's command to filter query logs, which are detailed in content and clear in logic. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article.

1. Query information that contains a keyword in the log

Cat app.log | grep 'error'2. Query the last 10 lines of the log

Cat-n 10 app.log3. Query the log of the first 10 lines of the log file

Head-n 10 app.log4. Query all logs after 10 lines

Tail-n + 10 app.log5. Query all logs in the log file except for the last 10 lines

Head-n-10 app.log6. The information in the query log containing a keyword shows the line number.

Cat-n app.log | grep 'keyword' 7. Display data of 102rows, the first 10 rows and the last 10 rows

Cat-n app.log | tail-n + 92 | head-n 208. Query according to the date and time period (the prerequisite log must print the date, and first determine whether there is a point in time through grep)

Sed-n'/ 2018-06-01 16 purge 0000 purl 20 lemonade. 2018-06-01 16 purl 06rime 36 gamble p 'app.log9. Use the more and less commands (paging, paging with spaces)

Cat-n app.log | grep "error" | more10. Save the log to a file

Cat-n app.log | grep "error" > temp.txt11. Import the log at a specified time into a file

Cat-n logs/catalina.out'/ 2020-01-01 00 logs/catalina.out'/ 0-01-01 00 cat 00 pay.out above are all the contents of this article entitled "what are the commands for filtering query logs?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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: 287

*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

Development

Wechat

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

12
Report