I'm trying to get rid of a hacker issue on some of my wordpress installs.
This guy puts 9 lines of code in the head of multiple files on my server... I'm trying to use grep and sed to solve this.
Im trying:
grep -r -l "//360cdn.win/c.css" | xargs -0 sed -e '1,9d' < {}
But nothing is happening, if I remove -0 from
xargs, the result of the files found are clean, but they are not overwriting the origin file with the
sed` result, can anyone help me with that?
Many thanks!
You should use --null
option in grep
command to output a NUL byte or \0
after each filename in the grep
output. Also use -i.bak
in sed
for inline editing of each file:
grep -lR --null '//360cdn.win/c\.css' . | xargs -0 sed -i.bak '1,9d'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With