0

I have a large number of sites with the same bit of php inserted in all files that contain footer in their filenames.

//###==###
malicious code
//###==###

How to use SED or another command to remove all these in all files?

Adamz
  • 21

1 Answers1

1

Try this with GNU find and sed to remove those lines in php files:

find /path/to/dir -iname "*.php" -exec sed -i -e '/^\/\/###==###/,/^\/\/###==###/d' '{}' \;
Cyrus
  • 931
  • 1
  • 7
  • 16
  • Perfect! thanks a bunch, Sed accepts a range? the comma is just a from this to this? A lot of other info on the web points to using lookahead switches etc this here is a much better way than all the perl methods I have found and elaborately concocted sed commands. – Adamz Mar 10 '15 at 07:01
  • Yes, sed can remove everything from matching line to matching line. – Cyrus Mar 10 '15 at 07:13