bash - question about grepping a specific time period
Hello,
I am fairly new to bash and have a question how I can accomplish the following: I have to grep in a logfile for a specific time period and print it out. For example: someone wants to get all results from a logfile from 21:05-21:10 How do print/grep that period? An example begin of a log entry: 2010-08-04 00:00:01,774 ERROR Thanks for any help. |
Hi,
In general: grep "2010-08-04 00:00:01" logfile If you want this range: 21:05-21:10 -> grep "21:0[5-9]" logfile The above example looks for the range 21:05:00 -> 21:09:59. The [5-9] part tells grep to look for everything from 5 t 9 (including both 5 and 9). Hope this helps. |
Hello,
Thanks that did the trick for me, I was using a loop but your example is lesser code and works perfectly :) Thanks! Michiel |
You're welcome :)
|
Quote:
|
Write a small program in awk/perl/php/whatever
|
All times are GMT -5. The time now is 09:50 PM. |