SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict Latox's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow 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.
    :-)

  2. #2
    Community Advisor silver trophy

    Join Date
    Nov 2006
    Location
    UK
    Posts
    2,521
    Mentioned
    37 Post(s)
    Tagged
    1 Thread(s)
    You can do this using a combination of find or grep to recurse through directory and 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)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •