Can I do a find and replace on all php files on my server, rather than individually?

Discussion in 'Site & Server Administration' started by ian_batten, Apr 29, 2008.

  1. #1
    Okay, so I'm updating to PHP5, and there is an instance in each php file for oscommerce that needs changing. However I have several hundred files, and I REALLY don't want to edit each one individually.

    I run a VPS, and have WHM and cpanel. Is there any way I can do a find and replace to search each file and replace the line of code on all of the files, or will I need to manually edit each one?

    Thanks in advance!
     
    ian_batten, Apr 29, 2008 IP
  2. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #2
    Dreamweaver can do site wide search and replace, both locally, and using FTP. If I need to do a search and replace on an entire site, I download the site and let Dreamweaver go nuts on the entire directory, then just upload the most recently changed files. I'm sure there's a better way, but it works for me.

    There's plenty of offline search and replace tools if you can be bothered downloading your site and running the search locally.. e.g this.
     
    Kerosene, Apr 29, 2008 IP
  3. gate2vn

    gate2vn Peon

    Messages:
    809
    Likes Received:
    33
    Best Answers:
    1
    Trophy Points:
    0
    #3
    on Linux, there is *replace* command for doing that. But you will need to run command in ssh, not from whm or cpanel
     
    gate2vn, Apr 29, 2008 IP
  4. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You could also run a script on the server and do the replacement using regular expressions. Of course make a backup of the original files before go running any kind of mass editing script or tool on them.
     
    LogicFlux, Apr 29, 2008 IP