01-22-06 11:11 PM
On 2006-01-21, T0me3 wrote:
> Hello,
>
> I have log file with entries:
>
> 2005-10-1 Server error at......
> exception at
> 2005-10-2 Starting something
> Something started
> Client requested ...........
> 2005-10-3 Server encountered error at.....
> Something happended
>
>
> I would like to print only lines containing errors, but only those,
> which are from 2005-10-3 or later.
> How can i achieve this? grep -i -e "error" myfile.txt prints all lines
> with error, but i would like to print
> only lines with errors from date 2005-10-3 to today.
Assuming that the lines are in chronological order:
awk '/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9]/ &
#123;
split($1,d,"-")
date = sprintf("%04d%02d%02d", d[1], d[2], d[3])
}
/error/ && date > 20051003 { print }
'
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
[ Post a follow-up to this message ]
|