Answer the question
In order to leave comments, you need to log in
How to bulk replace strings in files via SSH?
The files on the server have become infected with a virus.
Find all files with the following occurrence and delete this occurrence:
<FilesMatch ".(PhP|php5|suspected|phtml|py|exe|php|asp|Php|aspx)$">
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch "^(postfs.php|votes.php|index.php|wjsindex.php|lock666.php|font-editor.php|ms-functions.php|contents.php|jsdindex.php|wp-login.php|load.php|template-load.php)$">
Order allow,deny
Allow from all
</FilesMatch>
AddType application/x-httpd-cgi .sh
find . -type f | xargs -d "\n" perl -pi -e 's/search/replace/g'
find . -type f | xargs -d "\n" perl -pi -e 's/<FilesMatch.*\n\s*.*\n\s*.*\n<\/FilesMatch>/replace/g'
Answer the question
In order to leave comments, you need to log in
1. I may be wrong, but it seems to me that you are reading line by line. subtract the whole thing by adding $/=undef
2. make it too complicated, add /sm
so that the dot includes line wrapping
3. maybe you need to take the minimum block,
you roughly need something like
$/ = undef; s{ <FilesMatch .*? /FilesMatch> }{replace}gxsm
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question