Showing posts with label How to remove all .svn directories. Show all posts
Showing posts with label How to remove all .svn directories. Show all posts

How to remove all .svn directories from my application directories



xargs takes input, usually separated by newlines, and places them on the command line, so adding xargs makes what you had work:

find . -name .svn | xargs rm -fr

xargs is intelligent enough that it will only pass as many arguments to rm as it can accept. Thus, if you had a million files, it might run rm 1,000,000/65,000 times (if your shell could accept 65,002 arguments on the command line {65k files + 1 for rm + 1 for -fr}).

As persons have adeptly pointed out, the following also work:
find . -name .svn -exec rm -rf {} \; 
find . -depth -name .svn -exec rm -fr {} \; 
find . -type d -name .svn -print0|xargs -0 rm -rf 

The first two -exec forms both call rm for each folder being deleted, so if you had 1,000,000 folders, rm would be invoked 1,000,000 times. This is certainly less than ideal. Newer implementations of rm allow you to conclude the command with a + indicating that rm will accept as many arguments as possible:
find . -name .svn -exec rm -rf {} +