[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [^0-9] find patterns that are across multiple lines
From: |
TimtheEagle |
Subject: |
Re: [^0-9] find patterns that are across multiple lines |
Date: |
Sun, 11 Mar 2007 19:49:40 -0700 (PDT) |
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 <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."
>
>
>
>
--
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.