Mass Seach & Replace

My server is running linux, recently a lot of our files on our server (.html, .php and .js files) were edited by a hacker, and we want to do a mass search and replace on files with these extensions.

Does anybody know a command I can run in SSH to search and replace files with the extensions .php, .html and .js

For example:

Look in: .js, .html, .php
For: β€œ<script>hello</script>”
Replace with: β€œβ€

Thanks in advance. :slight_smile:

You can do this using a combination of find or [URL=β€œhttp://unixhelp.ed.ac.uk/CGI/man-cgi?grep”]grep to recurse through directory and [URL=β€œhttp://unixhelp.ed.ac.uk/CGI/man-cgi?sed”]sed to perform the replacement.

Make sure and test any solution offline before unleashing on a live server as there is the potential to annihilate your server if done wrong!
(you can use vmware player and a linux vmware image if you don’t have a test environment to hand)