the input would be like this in a file:


and the parsing looks like this:

sed -i "s/<script//g" SOMETHING.html

the "/gi" is not good, because OpenWrt doesn't knows it (busybox..):

sed: bad option in substitution expression

Does anybody know how could i delete e.g.: the:

< sCripT or 

with one sed?

Plus (the really thing i need): how could i delete the whole line containing

"<sCripT" or 
"<scRiPt", etc.?

I can't see a way using Busybox's sed, but you could use Busybox's sh and grep like this:

while IFS='
' read -r line; do
    printf "%s\n" "$line" | grep -qi '<script' || printf "%s\n" "$line"
done <SOMETHING.html >SOMETHING.html.tmp
mv SOMETHING.html.tmp SOMETHING.html
  • 1
    Correct (after minor fixes), but overly complicated compared with asoundmove's answer. There is a way with sed, but it's ugly: sed -e '/<[Ss][Cc][Rr][Ii][Pp][Tt]/d'. – Gilles 'SO- stop being evil' Mar 24 '11 at 20:02
  • @Gilles: I agree, asoundmove's is much simpler. – Mikel Mar 25 '11 at 0:24

Does the Busybox not have grep -v?

This should do the job in one simple command:

grep -vi "<[ \t]*script" SOMETHING.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.