How to grep the logs between two time range
21,992
From what I understand AWK can be used for this. As well, there's an answer on Stack Overflow already that looks like exactly what you want?
https://unix.stackexchange.com/questions/123979/how-to-extract-logs-between-two-time-stamps
Author by
john
Updated on May 29, 2020Comments
-
john almost 4 years
I have a log file
abc.log
in which content is like this when I do avi
on it.2015-05-28 18:12:00,815 INFO 0x7f6ed23e3700 send_to - recent: 1432861920 from dc:2 client_id: 102 2015-05-28 18:13:01,024 INFO 0x7f6ed23e3700 send_to - recent: 1432861980 from dc:2 client_id: 101 2015-05-28 18:13:42,244 WARN 0x7f6ed26e6700 mgr - Failed to upsert data for userid 3589109212161 with value cat and status -2 2015-05-28 18:14:00,135 INFO 0x7f6ed23e3700 send_to - recent: 1432862040 from dc:2 client_id: 103
I want to see the all the logs between this time frame:
2015-05-28 00:30:00 - 2015-05-28 02:30:00
So basically whatever logs I have between these time frame I want to see it in the same order in which it is there already. Is this possible to do using grep?
-
john almost 9 yearsThanks. In my case I don't have brackets around my date? How does awk script looks like then?
-
SwiftMango almost 9 years@david It is more than enough hints. You can easily get it if you know regular expression