View Single Post
Old 08-02-2012, 12:32 PM  
Barry-xlovecam
It's 42
 
Industry Role:
Join Date: Jun 2010
Location: Global
Posts: 18,083
Quote:
Originally Posted by fris View Post
I have a list of links.

example

Code:
<h3>search engine links</h3>
<a href="http://google.com">google</a>
<a href="http://www.bing.com">bing</a>
<a href="http://www.yahoo.com">yahoo</a>
<h3>payment links</h3>
<a href="http://www.paypal.com">paypal</a>
<a href="http://www.paxum.com">paxum</a>
i only want to get the search engine links being

Code:
<a href="http://google.com">google</a>
<a href="http://www.bing.com">bing</a>
<a href="http://www.yahoo.com">yahoo</a>
best way to go about this?

i was using sed, but its printing the 2nd h3

Code:
sed -n '/<h3>/,/<\/h3>/p' test.txt
any input would be great ;)
Fast and dirty -- should be in strict
in a foreach loop

Code:
Perl

foreach(@_){if ($_=~/href/ig)   {chomp $_; print FILE $_\n";}}
Barry-xlovecam is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote