Use SED to view logs for a specified time period of Linux

Source: Internet
Author: User
Tags syslog system log

For work reasons, to view the system log frequently, you can view the logs for a specified period of time with the following command:

#sed '/oct 06:*/,/08:*/!d '/var/log/syslog

This section shows all logs for the syslog October 26 morning at 6-8, and prints them out.


! D means: Delete all rows that are not selected and only keep all logs with a condition of 6-8 points in the morning, such as:


650) this.width=650; "Src=" Https://s1.51cto.com/oss/201710/26/f23c2656b6b7dce6e9e03f11159f98c3.png-wh_500x0-wm_3 -wmp_4-s_228778846.png "title=" Qq20171026095149.png "alt=" F23c2656b6b7dce6e9e03f11159f98c3.png-wh_ "/>


SED command:

! Indicates that the subsequent command has effect on all rows that are not selected.

d Delete, delete the selected row.


This article is from the Linux OPS blog, so be sure to keep this source http://kfensa.blog.51cto.com/7057855/1976278

Use SED to view logs for a specified time period of Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.