bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: find patterns that are across multiple lines


From: Benno Schulenberg
Subject: Re: find patterns that are across multiple lines
Date: Sun, 11 Mar 2007 22:14:34 +0100
User-agent: KMail/1.9.6

TimtheEagle wrote:
> 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.

Here is a possibility, very slow, that uses only 'grep'.  But it 
will also print the Framed-IP-Address field when this is not the 
third but the second or first line after the Username:

grep -B1 -A3 "Username = dthn" yourfile | grep -A4 "Acct-Status =" | 
grep -e Acct-Status -e Username -e Framed-IP-Address -e --

Benno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]