Link to home
Start Free TrialLog in
Avatar of http:// thevpn.guru
http:// thevpn.guruFlag for Denmark

asked on

Parse Log File..Get Result line + line after it..AWK ? GREP ? SED ? Regexp ?

I have the following expression

tail -n 100000 xmppd.log | sed -e '/iq type="set" id="iq-id:2/!d'

I need to get the result line(s) + the line directly following the result line...

I.e if Iam searching for xxx in

..... xxx....
.....yyy....
......ccc....

I want to get as as a result

....xxx...
....yyy...
Avatar of xDamox
xDamox
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi,

This can be done with grep for example say you have the value:

ccc
ccc
xxx
yyy
ccc

You can use the following:

grep -A 1 xxx

This would get the xxx line plus one line after the xxx
Avatar of http:// thevpn.guru

ASKER

Yep...I did that allright..however I am not at a new hurdle..how can I display only the last match of grep ?
ASKER CERTIFIED SOLUTION
Avatar of xDamox
xDamox
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
to match the last line..with grep use..
-m 1