[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: find patterns that are across multiple lines
From: |
Andreas Schwab |
Subject: |
Re: find patterns that are across multiple lines |
Date: |
Sun, 11 Mar 2007 23:42:33 +0100 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux) |
TimtheEagle <address@hidden> 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, address@hidden
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."