HobbitOfShire
HobbitOfShire

Reputation: 2414

Delete HTML code from log file in SHELL

I have a log file containing html code i need to delete all the content between html tags for every possible match in this file. How is that possible using filters?

Example of my file:

some text here
<html>
code
</html>
some text there
<html>
code
</html>
some other text

The output should be:

some text here
some text there
some other text

Upvotes: 0

Views: 87

Answers (2)

Kent
Kent

Reputation: 195079

why not just:

sed '/<html>/,/<\/html>/d'

it works for your example.

Upvotes: 1

Jotne
Jotne

Reputation: 41456

This awk should do:

awk '/<html>/{f=1;next} !f; /<\/html>/{f=0}' file
some text here
some text there
some other text

Upvotes: 1

Related Questions