Recursive search and replace from the command-line

I found myself having to change the name of a model in a Rails and Ember.js application. This meant changing not only the name of the model, but also the controller, the serializer, the stylesheets, along with the same thing on the Ember side of things. A quick recursive search and replace did the job:

find ./ -type f -exec sed -i -e 's/apple/orange/g' {} \;

So first all the files in all subdirectories from the current folder are found using find and then passed on to sed to do the regex replacement.

Write us your thoughts about this post. Be kind & Play nice.