http:// thevpn.guru
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...
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...
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
to match the last line..with grep use..
-m 1
-m 1
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