[Top][All Lists]

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

find patterns that are across multiple lines

From: TimtheEagle
Subject: find patterns that are across multiple lines
Date: Tue, 6 Mar 2007 12:46:00 -0800 (PST)

Hi folks,
I am trying to find a pattern that spans muliple lines.  It is to analyse
radius start and stop records for specific users.
I thought grep or awk was the answer but I am struggling with the multiple
line concurrent search.  
An example of the data is as follows:-

Acct-Status = Start
Username = address@hidden
next line content irrelevant
next line content irrelevant
next line content irrelevant

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.  So the output would be:-

Acct-Status = Start
Username = address@hidden

I am not sure if grep is the right tool and some may say that you should use
a database but I think that this sort of search would be very useful for
other things so it is worth pursuing.

Thanks for any help.
View this message in context: 
Sent from the Gnu - Grep mailing list archive at Nabble.com.

reply via email to

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