Removing lines of text with SED

This will remove a specific block of text between two pointers.

sed '/<script type="text\/javascript"/,/<\/script>/d' <filename>

..will remove all text between <script…> and </script> (Including the <script> tags.

Here is a short shell script to automate this for a bunch of files.

#!/bin/bash
# ALL HTML FILES
FILES="*.html"
# for loop read each file
for f in $FILES
do
INF="$f"
OUTF="$f.out.tmp"
# replace javascript
sed '/<script type="text\/javascript"/,/<\/script>/d' $INF > $OUTF
/bin/cp $OUTF $INF
/bin/rm -f $OUTF

admin has written 102 articles