SED help (or AWK!)
Thomas Pircher
tehpeh at gmx.net
Wed Jan 28 12:05:17 CET 2009
Steve McConville wrote:
> Actually it's just occurred to me that you could do something like
>
> for i in $(grep ^ORA output.log | sort | uniq) ; do grep -B 2 $i
> output.log | head -n 3 ; done
along the same lines, my version of the script (it might be the slowest of
all solutions posted on the list..)
The script will group the same errors in a common file. So beware: it will
clutter your working directory with files starting with "ORA-..."
Thomas
#!/bin/awk -f
BEGIN {
FS=":"
line0=""
line1=""
line2=""
}
{
line0 = line1
line1 = line2
line2 = $0
}
/^ORA-/ {
file = $1
print "--------------" >> file
print line0 >> file
print line1 >> file
print line2 >> file
print "--------------" >> file
}
More information about the CLUG
mailing list