Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a folder that has a .SVN solution in it.

I want to go throught the entire directory and its subdirectories, and delete the .svn folder.

I have bash installed, so I can use grep if need.

share|improve this question
find <path> -type d -name '.svn' -exec rm -rf {} \+

Finds all directories of name '.svn' and deletes them recursively.

I'd be really cautious of doing this if you don't own the checkout directory and don't understand why these directories are present. Also note roe's answer about svn export.

share|improve this answer
that should probably be -name and \; right? – falstro Dec 9 '09 at 16:02
Yeah, -nane was a typo :) The \+ tells -exec to call the command a bit more conservatively by appending arguments. – Dan Carley Dec 9 '09 at 16:04
sweet! I always used xargs for that, does it also terminate the command, or do I need to add a \; as well if I want more predicates? – falstro Dec 9 '09 at 18:22

in bash:

removesvn() {
  cd $1
  for f in */.svn; do
    [ -d "$f" ] && removesvn ${f%/.svn}
  [ -d "$f" ] && rm -rf .svn

removesvn .

should navigate down through all folders containing an .svn folder and remove it.

HOWEVER, you're probably better off using svn to export (svn export I beleive) a vanilla tree without versioning information, which is probably what you're looking for.

Note that the bash script above only removes .svn folders which are connected to the original one (i.e. it won't remove a/b/c/.svn if b doesn't contain a .svn). If you just want to clear out .svn stuff in your filesystem, find will probably do a better job.

share|improve this answer
+1 for svn export – Cristian Ciupitu Dec 9 '09 at 15:55

You can combine find and rm with xargs to find and remove all .svn subdirectories from a root directory.

First test the find command to check if it finds the right subdirectories,

find . -name ".svn"

This should display a list of all .svn subdirectories in the current working directory (.). Make sure that these are indeed the directories that you want to remove. Then run the following command to actually remove them (note: this cannot be undone),

find . -name ".svn" | xargs rm -vrf

See man rm and man find for an explanation of the options.

share|improve this answer

I used this technique:

find [path] -name .svn -print0 | xargs -0 rm -R

It worked just fine for me.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.