What are the commands for Linux to filter query logs
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.