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.

One Response to “How to rename your website with a for loop”

  1. Dustin’s Blog » Blog Archive » Another bash for loop time saver Says:

    [...] I’ve posted about for loops before and they are probably one of my most liked bash items. Here is another reason why. [...]

Leave a Reply