Printing the following line that matches an string

Hello,

I'm trying to process a log file like the following. Let's call it "log.txt"

2007-05-08 01:24:29,826 INFO - aaaaaaaaaa
2007-05-08 01:24:29,849 INFO - bbbbbbbbbbbb
2007-05-08 01:24:29,967 ERROR -
java.lang.Exception: etc
at xxx (xxx.java:95)
at zzz(zzzz.java:105)
2007-05-08 02:24:29,826 INFO - aaaaaaaaaa
2007-05-08 02:24:29,849 INFO - bbbbbbbbbbbb
2007-05-08 03:24:29,967 ERROR -
java.lang.Exception: error 2xxxx
at xxx (xxx.java:95)
at zzz(zzzz.java:105)
2007-05-08 03:24:29,826 INFO - aaaaaaaaaa
2007-05-08 03:24:29,849 INFO - bbbbbbbbbbbb

I would like to create a file with only the line that follows to the one which contains the text "ERROR -"

With grep 'ERROR -' > result.txt , i would get a new file with lines of the type:
2007-05-08 01:24:29,967 ERROR -
2007-05-08 03:24:29,967 ERROR -

What I would like is to get a new file that with the lines of the type:

java.lang.Exception: etc
java.lang.Exception: error 2xxxx

Any help or suggestion will be appreciated.

Regards,
Javier

Javier,
See if this would work for you:

sed -n "/ERROR/{N;p;}" input_file
sed -n "/ERROR/{N;D;p;}" input_file

Jean-Pierre.

Jean-Pierre,
I tried your solution and it didn't work -- could you verify please?
This would solve Javier's problem:

sed -n "/ERROR/{n;p;}" input_file

Shell_Life, you're rigth, must be :

sed -n "/ERROR/{N;D;};p" infile

It does the same that your solution but it is more complicated :wink:

Jean-Pierre.

With awk:

awk '/ERROR -/{getline;print}' infile