Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

the input would be like this in a file:

<sCripT

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 
"<scRiPt" 

with one sed?

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

"<sCripT" or 
"<scRiPt", etc.?
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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
share|improve this answer
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 Mar 24 '11 at 20:02
    
@Gilles: I agree, asoundmove's is much simpler. –  Mikel Mar 25 '11 at 0:24
add comment

Does the Busybox not have grep -v?

This should do the job in one simple command:

grep -vi "<[ \t]*script" SOMETHING.html
share|improve this answer
    
Yes, Busybox has grep -v as a non-optional feature. –  Gilles Mar 24 '11 at 20:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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