Parse file

Hi Friends,

I have a file in the format shown (Name followed by address:)
I need only the address part please see the output.
I have tried using nawk but I am not getting the desired output.

SAM
ADDRS 64874 FRANKLYN DR
IRVINE TX - 74394;
538 FRED ASSOCIATES
PETER
ADDRS 84734 PANTHER CREEK
OWENSMOUTH MI - 88347;
3643 HARRIS

**********************output

ADDRS 64874 FRANKLYN DR
IRVINE TX - 74394;
ADDRS 84734 PANTHER CREEK
OWENSMOUTH MI - 88347;

************

nawk 'BEGIN{RS="" ; FS = "\n"}
{
flag=0;
for( i = 1;i <= NF; ++i )
{
if (match ($i , "^ADDRS" ))
{ flag=1; break; }
}

if (flag == 1) print
}' a

******************************
Thanks a Lot in advance

S :slight_smile:

awk '{ if ( $0 ~ "^ADDRS" ) { print; getline tmp; print tmp } }' filename
sed -n "/^ADDRS/{N;p}" file

I would like to have the output between
"ADDRS" and ";" only
with this input I am not getting the address part.

Can you please help

SAM
ADDRS 64874 FRANKLYN DR
IRVINE TX -
'74394;
538 FRED ASSOCIATES
PETER
ADDRS 84734 PANTHER CREEK
OWENSMOUTH MI - 88347;
3643 HARRIS

sed -n "/^ADDRS/,/;/p" file

Thank you very much guys It worked