Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-08-02
4
Medium Priority
?
1,666 Views
Last Modified: 2008-02-26
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...
0
Comment
Question by:http:// thevpn.guru
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:xDamox
ID: 19615983
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
0
 
LVL 19

Author Comment

by:http:// thevpn.guru
ID: 19616045
Yep...I did that allright..however I am not at a new hurdle..how can I display only the last match of grep ?
0
 
LVL 16

Accepted Solution

by:
xDamox earned 1000 total points
ID: 19617251
Hi,

You could do something like:

grep -A 1 xxx <file we are parsing> | tail -n 2

0
 
LVL 19

Author Comment

by:http:// thevpn.guru
ID: 19692238
to match the last line..with grep use..
-m 1
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question