Need help with a recursive Linux search & replace

Discussion in 'Site & Server Administration' started by embarq, Jun 1, 2010.

  1. #1
    I'm trying to use find and sed to recursively search and replace a URL on my server but I can't seem to get the regex just right. If anyone is really familiar with doing this could you please shoot me a PM? I can paste what I have and if you could take a look at it I'd really appreciate it. Thanks!
     
    embarq, Jun 1, 2010 IP
  2. phpcat

    phpcat Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I suggest you download all files, then run a search/replace on your own computer and then re-upload the files.
     
    phpcat, Jun 2, 2010 IP
  3. sysadmin

    sysadmin Peon

    Messages:
    111
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello,

    Do you have shell access if so ssh to your server and go to the folder and run the following command

    find ./ -type f -exec replace 'http:///oldurl/' 'http://newurl' -- {} \;

    If not like it try the second one as follows
    for i in `find ./ -type f ` ; do replace 'http:///oldurl/' 'http://newurl' -- $i ; done
     
    sysadmin, Jun 3, 2010 IP