LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-24-2010, 03:18 AM   #1
guessity
Member
 
Registered: Dec 2009
Posts: 41

Rep: Reputation: 15
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.
 
Old 03-24-2010, 03:26 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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
 
1 members found this post helpful.
Old 03-24-2010, 03:32 AM   #3
guessity
Member
 
Registered: Dec 2009
Posts: 41

Original Poster
Rep: Reputation: 15
It works.. cool. Thx.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
remove all links from a file with grep steve51184 Linux - Software 14 02-04-2009 12:09 AM
Remove lines in a text file based on another text file asiandude Programming 10 01-29-2009 11:59 AM
Remove text from a file jviola Programming 23 03-21-2007 01:23 PM
remove \r and \n from a text file powah Programming 9 10-02-2006 07:02 AM
remove some text from a file hfawzy Programming 7 07-10-2006 10:22 PM


All times are GMT -5. The time now is 01:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration