How to extract certain lines from a file?

Hi guys
I have a several thousands line file in the following format:

n817
--------------------------------------------------
n842
--------------------------------------------------
n877
--------------------------------------------------
n513
/bb/data/rmt2db.lrl:JBSKDB 31915 75
/bb/data/rmt3db.lrl:RELFUDB 19263 75
--------------------------------------------------
n943
--------------------------------------------------
n944
--------------------------------------------------
n655
/bb/data/rmtdb.lrl:ARBITDB 2672 75
--------------------------------------------------

Is there a way to extract ONLY the lines which contain
".lrl" entry together with the node above it, so the output will looks like this :

n513
/bb/data/rmt2db.lrl:JBSKDB 31915 75
/bb/data/rmt3db.lrl:RELFUDB 19263 75
--------------------------------------------------
n655
/bb/data/rmtdb.lrl:ARBITDB 2672 75
--------------------------------------------------

Thanks a lot for any advice. -A

Try sth like this..

 
grep -A 1 -B 1 "\.lrl" file

Thanks a lot pamu, but I keep getting the following message when I am running the grep:
"grep: Not a recognized flag: A"
It looks like my shell (ksh88) does not take it... :frowning:

with awk

 
awk '/\.lrl/ && !p{print s;a=1}
a{print $0;p=1}
! /\.lrl/{a=p="";s=$0}' file

Thanks a lot pamu. It worked as a charm :slight_smile: