从主文件夹中的所有 index.php 文件中递归删除字符串

1 shell-scripting

我们需要一个 shell 脚本来查找和替换 /home 文件夹中所有 index.php 文件中的一段注入代码

cor*_*ump 5

你可以用 sed 做到这一点。这是一个很好的教程。它可能很简单find /home/user -iname index.php -exec sed -i s/<piece of code to find/<replace with that>/ {} \;

我建议您在执行此操作之前进行备份并运行一些测试以查看它是否正常工作。请记住,// 之间的内容是正则表达式,根据其格式,您可能会匹配更多您需要的内容。正如我所说,在您的“实时”文件上运行之前进行测试。

编辑:修复了 find 命令,感谢 rems