1

First, I am using GNU userland so you can assume I use Bash, GNU coreutils...

I have a HTML and I want to change all

href="foobarz"

into

href=""

However, I don't want to change any line containing the word css (not case-sensitive)

'href="fooCsSbarz"'

should remain unchanged

I am currently using the command

$ cat foo.html | sed -e 's/href="[^"]*"/href=""/g' > bar.html

but it cannot retain those lines containing the word css (not case-sensitive)

Actually, any tool available in *nix is welcomed, like sed, awk, perl...

Thank for your help!

1

From here.

You can use:

sed '/[Cc][Ss][Ss]/! s/href="[^"]*"/href=""/g' foo.html > bar.html
  • Thanks a lot! That thread 's title is not 'grep-friendly'... – Alex Vong Apr 8 '15 at 4:12

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.