LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 02: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, 02:26 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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, 02:32 AM   #3
guessity
Member
 
Registered: Dec 2009
Posts: 41

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


Reply



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-03-2009 11:09 PM
Remove lines in a text file based on another text file asiandude Programming 10 01-29-2009 10:59 AM
Remove text from a file jviola Programming 23 03-21-2007 12:23 PM
remove \r and \n from a text file powah Programming 9 10-02-2006 06:02 AM
remove some text from a file hfawzy Programming 7 07-10-2006 09:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:40 PM.

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
Open Source Consulting | Domain Registration