in reply to Re^3: need to extract top and bottom lines...
in thread need to extract top and bottom lines...

Oops, something ate the square brackets around the negated character class ^12. Maybe code tags will help, maybe not.

perl -ne 'sub BEGIN {$l="";}$l=$_, next unless /ERROR/;print /^[^12]/ +? "$l$_" : $_;$l=$_;' some.log

Johngg