Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

Find and replace many files at once



9:57 am on Jun 10, 2012 (gmt 0)

10+ Year Member


Due to a server error we lost the content of 10 of our sites, many of them very, very old. We have been compressing our backups and uploading them the last couple of days. Now that the server is ready, we face a problem: many of the .html, .php and .shtml files have absolute paths that have changed a lot. We have tried to change them like this:

find backupPath -type f | xargs perl -pi -e 's/obscenelyLongOldPath/\/newPath\/public_html\//g'

Thing is, it seems to run for a couple of files and then stops. It doesn't even affect subdirectories. Do you guys know a way to make this? Thanks in advance!


9:19 pm on Jun 10, 2012 (gmt 0)

10+ Year Member

Nevermind, found a way:

cd rootPath
find . -type f -print0 | xargs -0 sed -i 's/obscenelyLongOldPath/newPath/g'

Featured Threads

Hot Threads This Week

Hot Threads This Month