Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to do this in Ubuntu? I've read it's possible in php, but I'm not familiar with php at all.

share|improve this question
up vote 1 down vote accepted

You could use sed for that, but it will only work for links that are in a single line in the html code.


Damn greedy regex! ;) This one should work now!

sed -i 's|<a[^>]\+>|<a>|g' <the-html-file>

share|improve this answer
It's behaving oddly! Deleting all the sentences, after a link anchor in a paragraph till next link anchor, which is not being removed. Leaving many links as is. :( – 22lk94k943 only May 29 '13 at 19:56
Can you give a Sample file? – ortang May 29 '13 at 20:10
I have updated my answer – ortang May 30 '13 at 12:42
Damn! It's working like a knife on cheese. Thanks a lot. It will be highly educational if you can add the description of "Greedy regex" to the answer. – 22lk94k943 only May 30 '13 at 15:09

Depends what you are trying to do:

If you have a pile of files on your machine, and you want to remove the links, use something like a wee perl script to remove the <a ...> ... </a> tags. You can remove other tags (or even all tags) in a similar way. With the right pattern matching options, this approach can handle tags split across multiple lines. (It's very elegant, but the details won't fit in the margin of this post).

If you are trying to browse files on some webserver, using firefox (or other browser), some kind of greasemonkey script that automatically modifies pages on the fly, before showing them, might be what you want.

Search here or Google for details - or check for other answers :-)

Need to reboot now - good luck!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.