LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How can I remove all the <a href links from text file? (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-remove-all-the-a-href-links-from-text-file-797479/)

guessity 03-24-2010 02:18 AM

How can I remove all the <a href links from text file?
 
Quote:

<a class=link target=_parent href=www.google.com>Google</a> &nbsp;&nbsp; <a class=link target=_parent href=http://www.yahoo.com>Yahoo</a> &nbsp;&nbsp; <a class=link target=_parent href=http://www.live.com>Live</a> &nbsp;&nbsp;
I am trying to remove <a href links using SED but unable to do it.

The finale result I am looking for is

Quote:

Google &nbsp;&nbsp; Yahoo &nbsp;&nbsp; Live &nbsp;&nbsp;
Is it possible with Linux or should I try with Php? Please help me.

Tinkster 03-24-2010 02:26 AM

Something like that?
Code:

echo '<a class=link target=_parent href=www.google.com>Google</a> &nbsp;&nbsp; <a class=link target=_parent href=http://www.yahoo.com>Yahoo</a> &nbsp;&nbsp; <a class=link target=_parent href=http://www.live.com>Live</a> &nbsp;&nbsp;' | sed -r 's/<a class=link target=_parent href=[^>]+>//g;s/<\/a>//g'
Google &nbsp;&nbsp; Yahoo &nbsp;&nbsp; Live &nbsp;&nbsp;


Cheers,
Tink

guessity 03-24-2010 02:32 AM

It works.. cool. Thx.


All times are GMT -5. The time now is 11:06 PM.