Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a log file which has entries like below. I want to find only the log entries newer than a given time. What would be a suitable shell script for it?

[2013-06-23 21:31:19,972]  INFO 
[2013-06-23 21:31:20,148]  INFO 
[2013-06-23 21:31:20,148]  INFO 
[2013-06-23 21:31:20,195]  INFO 
share|improve this question
1  
May be this will help you unix.stackexchange.com/questions/80088/… –  cuonglm Jun 23 '13 at 17:43
    
You might be able to use my answer here as the basis for what you need. –  Dennis Williamson Jun 24 '13 at 1:53

1 Answer 1

up vote 2 down vote accepted
awk -v giventime="2013-06-23 21:31:20,150" '$1" "$2 < "["giventime"]"' logfile

If you want to specify the "given time" in a different format, we can accomodate you, but let us know.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.