I am trying to figure out why this command is not working for me:
sed -n -e '/<a href=\(.*\)>/,/<\/a>/p' text.html
On text.html we have something like...
<somestupidstuff> <a href='teste'> teste </a> </somestupidstuff>
The desired output is:
<a href='teste'> teste </a>
But what I get is:
<somestupidstuff> <a href='teste'> teste </a> </somestupidstuff>
Maybe I am not fully understanding the regex.
sed
expression is doing is printing all the lines between the matches of/<a href=\(.*\)>/
and of/<\/a>/
. If this is a well formed XML document, you may want to look into using an XML parser instead, such asxmlstarlet
.