Delete Wildcards or Directories Recursively

I was cleaning up my Subversion backup which contains hidden .svn directories which I didn’t want. I have about 15 subdirectories, each one having three directories underneath them that contain the .svn directory. To remove all the .svn directories recursively, I needed to perform the command below via the Terminal:

To Delete Files Recursively

If you just want to recursively delete files, for example, that are called “svn.txt” in the svn directory, you will need to use this:

sudo rm 'find -name "svn.txt" | grep svn'

To Delete Directories Recursively

If you want to delete several directories with a same name, using the wildcard. I had to use the “-rf” switch since .svn are directories.

sudo rm -rf 'find -name ".svn" | grep svn'

These commands worked for me. Just to be perfectly sure, backup your files and perform a test first.