How can I remove all script blocks (including multi-line ones) from html files such as:<script type=text/javascript>var googletag = googletag || {};googletag.cmd = googletag.cmd || [];(function() {var gads = document.createElement('script');gads.async = true;gads.type = 'text/javascript';var useSSL = 'https:' == document.location.protocol;gads.src = (useSSL ? 'https:' : 'http:') +'//www.googletagservices.com/tag/js/gpt.js';var node = document.getElementsByTagName('script')[0];node.parentNode.insertBefore(gads, node);})();</script>I tried things like this with no success:sed -i -e 's/<script.*\n.*<\/script>//g' 'path/to/file.html'
How can I get rid of all script blocks in html files?
shell script;sed
With sed you can select ranges and delete them:sed '/<script/,/<\/script>/d' inputfile