How to rename your website with a for loop

I recently found myself renaming a website and needed to change some common text in a bunch of php and template files. Here is the code I used to get the job done.

for I in `find . -name "*.php"`; do sed -i "s/old name/new name/g" $I; done
for I in `find . -name "*.tpl"`; do sed -i "s/old name/new name/g" $I; done

Sure a truly savvy person could have done this in one line but that’s just not as fun.

1 comment

Leave a Reply

Your email address will not be published. Required fields are marked *