Redbox
Redbox

Reputation: 1477

using sed and grep to erase html

i have a code like this:

<html>
<body>
<div>some normal html code</div>
<!--f1930e-->
some javascript code goes here...
<!--/f1930e-->

some other html....
</body>
</html>

how do i remove the part of:

<!--f1930e-->
some javascript code goes here...
<!--/f1930e-->

so that it become:

<html>
<body>
<div>some normal html code</div>
some other html....
</body>
</html>

my command is like this:

grep -lr -e 'f1930e' * | xargs sed -e 's/<!--f1930e-->.*<!--\/f1930e-->//'

that is not working.

Upvotes: 0

Views: 55

Answers (1)

Gilles Qu&#233;not
Gilles Qu&#233;not

Reputation: 185171

Try this in your :

$ sed '/<!--f1930e-->/,/<!--\/f1930e-->/d' file.html
<html>
<body>
<div>some normal html code</div>

some other html....
</body>
</html>

If you want to really modify the file, add the -i switch to .

Upvotes: 1

Related Questions