Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 accidentally deleted my .svn folder in the root directory on the site I'm working on. So I need to remove all .svn from this project, do a fresh checkout, then overwrite that checkout with what I have. Problem is, I'm not sure how to recursively delete directories in linux.

share|improve this question
up vote 4 down vote accepted

It sounds like you want to delete all instances of the .svn directory from a tree, but leave all the other data intact.

find <checkout_root> -name .svn -type d -exec rm -rf {} \;
share|improve this answer
You may need to escape the brackets as well, like so: find <checkout_root> -name .svn -type d -exec rm -rf \{\} \; – Mark Porter Apr 9 '10 at 15:47
The brackets don't need to be escaped. – Warner Apr 9 '10 at 16:15

Find makes this task painless.

$ find /path/to/files -name '.svn' -exec rm -rf {} \;

Though you may wish to run one with an echo first to verify the files before you're deleting them.

$ find /path/to/files -name '.svn' -exec echo {} \;

share|improve this answer
+1 for being careful first! – David Mackintosh Apr 9 '10 at 15:35
-exec echo {} \; can be replaced by -print (or nothing at all, since find does that by default). – grawity Apr 11 '10 at 20:44
find /path/to/files -name .svn -type d -print0 \
    | xargs --null --no-run-if-empty rm --recursive --force --
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.