SED help (or AWK!)

Simon Andrews simon.andrews at bbsrc.ac.uk
Wed Jan 28 11:32:06 CET 2009


On 28 Jan 2009, at 10:11, Longman wrote:

>
> Hi peeps.
>
> I want to copy a load of data from a log file that starts 'ORA-' and  
> put
> the lines into another file.  Basically I have a load of Oracle errors
> in a log file and the file is very big and I am interested in only the
> errors (file is 700MB but I hope that there are less than 1MB of  
> errors!).
>
> Example:
>
> ERROR at line 1:
> ORA-00904: "TIMESTAMP": invalid identifier
>
> And something like ?
>
> sed -n '/ORA/w output.log' errors.txt
>
> But that will not give me unique errors.  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.

How about

grep -B 2 ^ORA output.log > errors.txt

Simon.




More information about the CLUG mailing list