Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I have a file that is mixed with both normal text I need and html-tags. I know that with REGEX it is possible to recognize html tags and with sed one can swap those for an empty string, but I do not know how to apply it concretely.
As long as your HTML tags are confined to a single line, the following will work:
<tag attribute="legal use of >" foo=bar>
<!-- > -->
If you are not insisting on sed, the best thing to do this would be lynx.
lynx --dump <filename>.html
This will output the content of the html file in the format the html code was intending to display. The only condition is that the filename should have a .html or .htm extension.
I strongly recommend the use of either of the programs named html2text (1) (2) instead. Parsing HTML is much harder than it looks.
Required, but never shown