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!)

Recursively remove all .svn directories (See related posts)

find . -name .svn -print0 | xargs -0 rm -rf


Update: Thankyou iburrell

Comments on this post

iburrell posts on Aug 08, 2005 at 02:33
That isn't the best way to do it. It will break if you have lots of .svn directories. Then the command line will be too long and you will get 'argument list too long'. Recent bash have enormous buffers so this is less of a problem. xargs solves this problem.

The other problem is any file with spaces in the name will cause bash to treat it as two arguments. Which could give an error or could delete the wrong file. find -print0 and xargs -0 solve this problem.

find . -name .svn -print0 | xargs -0 rm -rf


The other way is to do:

find . -name .svn -exec 'rm -rf {}\;'

nocans posts on May 31, 2008 at 22:57
find . -name .svn -exec 'rm -rf {}\;'

Doesn't work on solaris. Use this for all unixes:

rm -rf `find . -name .svn`

You need to create an account or log in to post comments to this site.