Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: How to filt...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 5 Topic 2170 of 2236
Post > Topic >>

Re: How to filter out lines?

by "John W. Krahn" <someone@[EMAIL PROTECTED] > Feb 24, 2008 at 11:11 PM

Viatly wrote:
> Given a stdout of some prog, I have to filter out 2-line blocks of
> text, where the first line contains "marker1" and the second line
> contains "marker2".
> Thus, for the following output
> 
> some text..
> more text...marker1...moretext
> more text...marker2...moretext
> more text..
> more text...marker1...moretext
> more text..
> more text...marker2...moretext
> more text...
> 
> after applying the filter I shell get
> 
> some text..
> more text..
> more text...marker1...moretext
> more text..
> more text...marker2...moretext
> more text...

$ echo "some text..
more text...marker1...moretext
more text...marker2...moretext
more text..
more text...marker1...moretext
more text..
more text...marker2...moretext
more text..." | \
     perl -ne'/marker1/ and $_ .= <> and /marker2/ and next; print'
some text..
more text..
more text...marker1...moretext
more text..
more text...marker2...moretext
more text...




John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall




 5 Posts in Topic:
How to filter out lines?
Viatly <postoronnimv77  2008-02-24 11:38:03 
Re: How to filter out lines?
Luuk <Luuk@[EMAIL PROT  2008-02-24 21:16:28 
Re: How to filter out lines?
Ed Morton <morton@[EMA  2008-02-24 15:20:35 
Re: How to filter out lines?
"John W. Krahn"  2008-02-24 23:11:32 
Re: How to filter out lines?
William James <w_a_x_m  2008-02-24 19:21:08 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 2:30:59 CDT 2008.