什么是 *nix 终端命令来查找和删除找到的文件?

Ale*_*eds 2 linux terminal grep malware

我的服务器上有恶意软件。所以我想出了如何找到所有恶意文件

 grep -r --include*.php "Some String from files" .
Run Code Online (Sandbox Code Playgroud)

这似乎工作正常!

但如何删除它们?我试过使用 xargs

grep -r --include=*.php "FilesMan" . | xargs -I {} rm {}
Run Code Online (Sandbox Code Playgroud)

但是得到了

rm: cannot remove `./www/wp-content/plugins/zuglohjetok/vaoaddiy.php:$default_action = FilesMan;': No such file or directory
Run Code Online (Sandbox Code Playgroud)

有人可以分享一些神奇的代码行吗?

而且我还尝试通过“查找”查找服务器上所有最近修改过的文件,但这给我带来了大量文件。有没有其他花哨的方法来查找恶意软件或受感染的文件?

Ign*_*ams 5

find some/dir -iname '*.php' -exec grep -q "some string" {} \; -delete
Run Code Online (Sandbox Code Playgroud)

使用-print而不是-delete首先确保命令按预期工作。