替换服务器上所有php文件中的特定文本位?
So I just got my sorry ass hacked, the hack put some obscure string in almost every one of the php files on my website. How can I remove every instance that line occurs?
The code it added started with <?php
so therefore I cannot simply replace it with blank, I need to delete it and move up the actual relevant code up one line as <?php
cannot start on a white space...
所以我只是把我的抱歉屁股黑了,黑客在中放了一些模糊的字符串 em> 我网站上的每一个php文件。 如何删除该行发生的每个实例? p>
它添加的代码以&lt;?php code>开头,因此我不能简单地将其替换为空白,我需要 要删除它并将实际相关代码向上移动一行,因为
&lt;?php code>无法在空白处开始...... p>
div>
Your favourite IDE probably already have a find/replace in files/project function. If not try Notepad++ Press Ctrl-Shift-F to open the Find in Files dialog where you can specify the root folder, a *.php file filter and then use either the regular expression option or extended code option to zap the unwanted code. If you post a sample of a hacked file we might be able to help you with the exact string to specify.
Try this:
find ./ -type f -name *.php -exec sed -i 's/stringtofind/stringtoreplacewith/g' {} \;
or this:
perl -p -i -e 's/stringtofind/stringtoreplacewith/g' `grep -ril stringtofind *`