SED help (or AWK!)

Jeremy Henty onepoint at starurchin.org
Wed Jan 28 12:00:21 CET 2009


On Wed, Jan 28, 2009 at 10:11:55AM +0000, Longman wrote:

> sed -n '/ORA/w output.log' errors.txt
> 
> But that will not give me unique errors.

grep '^ORA-' output.log | sort -u

> Also I'd like to have two lines above the match (like greps -C
> context option) so that I can see the SQL that failed.

Sheesh!

grep -B 2 '^ORA-' /tmp/output.log |
perl -0777 -wne '
my %foo;
s|((^.*\n){3})(^.*\n)?|$foo{$1} = 1|gme;
print sort keys %foo;
'

Regards,

Jeremy Henty



More information about the CLUG mailing list