extract information from Unix log file based on timestamp

Dear experts -

        I have huge server log file. I would like to retrieve information from the logfile between
8/29/13 17:16:37:514 GMT  and 8/29/13 18:16:37:514 GMT.   I wanted to put the information into a different file for some error research.

        Can you please help? This is on solaris 10

Regards
akp007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pepe2323Commented:
Hi

My idea to get something like this will be use grep.

grep "8/29/13 17:" /var/adm/messages >> /var/tmp/message-at17.log-- i'm assuming you are looking the error on the message file

to get info of that date the whole period of 17hrs
 
grep "8/29/13 18:" /var/adm/messages >> /var/tmp/message-at18 to get info of that date the whole period of 18hrs

I hope this help to have a smaller log file

Regards.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
akp007Author Commented:
Thanks . I don't have error message to grep on. We know the error happened between the timings.

But what happens with your suggestion, it will grab all the lines that has the time stamp, but there will be some content followed by that time stamp right? , it won't be picked up.

Regards
0
skullnobrainsCommented:
assuming the lines start with the dates in the provided format, this should do

sed -ne '/8\/29\/13 17:16:37:514/,/8\/29\/13 18:16:37:514/ p' /path/to/log/file

sed will start printing at the first matching line and stop likewise so you'll only get the first line timestamped at 18:16:37. if this is an issue, add one second

note that there are much more efficient ways to lookup for a date i a log file than using sed but you won't do it using shell scripting
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.