I have server log in the following format and I want awk which can extract logs between 2 dates.
Log Format:
00:00:00,002 INFO [LOG.XXX] XXX
01:11:00,001 INFO [LOG.XXX] XXX
02:00:01,002 INFO [LOG.XXX] XXX
SOME JUNK
02:02:00,002 INFO [LOG.XXX] XXX
03:11:00,001 INFO [LOG.XXX] XXX
SOME JUNK
03:00:00,002 INFO [LOG.XXX] XXX
04:00:00,001 INFO [LOG.XXX] XXX
10:00:01,002 INFO [LOG.XXX] XXX
10:59:01,002 INFO [LOG.XXX] XXX
12:03:01,002 INFO [LOG.XXX] XXX
Here, I want to fetch logs between Time: 01 to 10
Output
01:11:00,001 INFO [LOG.XXX] XXX
02:00:01,002 INFO [LOG.XXX] XXX
SOME JUNK
02:02:00,002 INFO [LOG.XXX] XXX
03:11:00,001 INFO [LOG.XXX] XXX
SOME JUNK
03:00:00,002 INFO [LOG.XXX] XXX
04:00:00,001 INFO [LOG.XXX] XXX
10:00:01,002 INFO [LOG.XXX] XXX
10:59:01,002 INFO [LOG.XXX] XXX
Options That I tried:
I can grep the time stamp with "-n" option and then cut those line number with sed command. But Issue with this approach is my log file is in GB and this makes it very slow, so I want awk to serve this purpose.
You can do it with awk