Thanks a lot - final awk script is below for the record.  Had some minor
syntax errors in my original sample data.

awk '/Acct-Status-Type =/{ last_acct_status = NR; as = $0 }/User-Name =
\"dthn/ && last_acct_status + 1 == NR {last_user_name = NR; print NR-1 as;
print NR $0 }/Framed-IP-Address = 10\.230\.4\./ && last_acct_status + 4 ==
NR { print NR $0 }' inputfilename

Tim


Andreas Schwab wrote:
> 
> TimtheEagle <[EMAIL PROTECTED]> writes:
> 
>> So I want to find and print the lines that have "Acct-Status =" on the
>> line
>> directly above "Username = dthn" and also display the line beginning with
>> "Framed-IP-Address=10.240.4." where this line is the 3rd line after this
>> specific Username line.
> 
> Use awk or perl.
> 
> $ awk '/Acct-Status =/ { last_acct_status = NR; acct_status = $0 }
>        /Username = dthn/ && last_acct_status + 1 == NR {
>             last_username = NR; print acct_status; print }
>        /Framed-IP-Address=10\.230\.4\./ && last_user_name + 3 == NR'
> 
> Andreas.
> 
> -- 
> Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
> SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
> PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/find-patterns-that-are-across-multiple-lines-tf3358168.html#a9427745
Sent from the Gnu - Grep mailing list archive at Nabble.com.



Reply via email to