Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

If I try wget on a webpage, I am getting the page as html. Is it possible to retrieve only text of a file without associated html ? (This is required for me since some of the HTML pages contains c program is getting downloaded with html tags. I have to open it in browser and manually copy the text to make a .c file.)

share|improve this question
Actually it is possible, but you need to write some function that will parse the code from the page and save it as .c. It is not hard, but it depends on page structure. If you provide a link may be somebody will help you with exact code. Otherwise sed or perl are your friends. – rush Jul 9 '12 at 8:28
up vote 15 down vote accepted

wget will only retrieve the document. If the document is in HTML, what you want is the result of parsing the document.

You could, for example, use lynx -dump -nolist, if you have lynx around.

lynx is a lightweight, simple web browser, which has the -dump feature, used to output the result of the parsing process. -nolist avoids the list of links at the end, which will appear if the page has any hyperlinks.

As mentioned by @Thor, elinks can be used for this too, as it also has a -dump option (and has -no-references to omit the list of links). It may be especially useful if you walk across some site using -sigh- frames (MTFBWY).

Also, keep in mind that, unless the page is really just C code with HTML tags, you will need to check the result, just to make sure there's nothing more than C code there.

share|improve this answer
Or use elinks which has support for frames. Use -no-references to achieve the same effect as nolist for lynx. – Thor Jul 12 '12 at 23:01
@Thor, thanks, I updated the answer to mention that. – njsg Aug 8 '12 at 8:30

just to add another tool. I prefer w3m, which is a lynx like console browser. You may want to check out whats already available on your system.

w3m -dump website.html
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.