I want to remove following javascript from html file.
<script src="text/javascript>
alert('hello');
})();
</script>
and
<script src="text/javascript>
alert('hello');
} catch(err) {}</script>
By reading http://www.cyberciti.biz/faq/sed-howto-remove-lines-paragraphs/ I can use:
sed '/<script type="text\/javascript"/,/<\/script>/d'
but it will remove all the javascript.
My specific requirement is javascript one ending with })(); (new line)</script>
and other ending with } catch(err) {}</script>
I want to use sed, if not possible then any program similar to sed so that I can run it through script.
Thank you for taking your time.
ghostdog74 :
Use awk or a programming language of your choice\n\nawk -vRS=\"</script>\" '/<script/ { if(/}\\)\\(\\);|catch\\(err\\)/) { gsub(/script.*/,\"\");} }1' file\n",
2011-04-23T11:22:30