"Linux" Log analysis tool grep sed sort

Source: Internet
Author: User

Encountered a problem when querying the log found that there are many files printed on the server, each of which stores a portion of the log, the log needs to be sorted by time and all logs are displayed.

Original command:

grep-h searchcontent */*log

The search results will show all the contents in the following format:

File1.log: time ....

File2.log: time ....

Because the log after the file name also contains :, so the use of separators : The method of separating sorting is not feasible, at this time, you need to not include the file name in grep, after searching for a pass, find a parameter "-H", Can not display file name

grep-h searchcontent */*log

Now the log shows that it meets the requirements, and the sorting can be done to sort the display log by time

grep-h searchcontent */*log | sort

Refer to the connection and keep learning:

Http://www.cnblogs.com/dmcpxy/archive/2012/02/28/grep-normal-usage.html

Https://www.cnblogs.com/51linux/archive/2012/05/23/2515299.html

http://blog.csdn.net/teamlet/article/details/38046409/

"Linux" Log analysis tool grep sed sort

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.