Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Rob Nugen http://robnugen.com

bash shell code to replace text in multiple files, multiple dirs, (but not in SVN dirs)

find . -name          *.php -exec sed -i 's/oldtext/newtext/g' {} \;
find . -name .svn -prune -o -exec sed -i 's/oldtext/newtext/g' {} \;


My understanding:

find files starting with . (local directory)

-name .svn -prune means if you find .svn for a filename (directory name), skip it.

-o OR

-exec execute

sed -i sed is the stream editor. -i means change the files in place.

's/new/old/g' Substitute old text for new text Globally.

{} sends the filenames that find found to sed

\; terminates the -exec from find, and \ escapes it so the shell won't think it means to end its command.