Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-08-02
4
Medium Priority
?
1,653 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

721 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