this is a W you motherfucker! this is a W you motherfucker!
top about projects my photos rc stuff contact home
News/my blog discussion

Search and replace; this saved my day!
16/4/2011 Filed in: Programming

Hello all!

I just moved my server, maybe you've noticed that, and my webserver is now nginx! Much faster and uses less memory that Apache.

But to the "nasty" part. I had to replace some strings in some files -- many different places. I did NOT want to manually sit and do search and replace. Because of that I found this way of doing it with a simple command (disclaimer; found a variation of it somewhere on the net).

Here it is;

find ./ -type f -exec sed -i 's/SEARCHTERM/REPLACETERM/g' {} \;

Remember that if you need to search and replace a string with / in it you need to terminate all the / slashes.

This command will recursively move through all folders and replace the searchterm in all files in these folders.


mysteries dot © 2009-2017 design/code Tobias Westergaard Kjeldsen