Originally Posted by vaw
I have a log file, which has data similar to :
[2011-11-11 00:33:53,962] xyz
[2011-11-21 01:28:01,269] abc
[2011-11-30 00:52:56,444] bcd
I want to be able to pull out data that is less than 24 hurs old from this file, so that on a daily basis i can get a report having data of last 24 hours.
Could you please let me know, using unix, how can i filter the data that i need ?
Similar question to your other thread, where someone even wrote you a script to do something similar. Have you tried to modify that? You can also just use grep to look for whatever string you want, and save those results into another file.
You can also use logrotate, and have it set to archive log files every day, so that your logs will only EVER have 24 hours of data in them, going back as far as you'd like. Read the man pages on grep and logrotate.