I'm still learning the bash shell.

I want to recursively find and remove svn files within the child directories of a given folder. I made the mistake of checking out instead of just cloning, so I'm trying to clean up my mess.

I've tried this, but I only get output of all the files found:

rm | find -name ".svn"

When I run this, I get no output and the files are still there: find . -executable -o ! -regex '.*\.svn' -exec rm -i {} \+


The easier method would be to export the revision you want instead of checking it out. Try svn help export at the bash shell.

If you really want to use find to go through and remove all child directories called .svn you would do this:

find /path/to/search -type d -iname .svn -print0 | xargs -0 rm


  • -type d #look for directories only
  • -iname .svn #case insensitive matching, probably not necessary
  • -print0 #prints the full file name followed by a null character instead of newlines. it allows file names with spaces or other whitespace to be passed properly to xargs -0
  • Yeah i made the mistake of not exporting so i'm trying to clean up my mess. I'll give that a try. Could you break down what you did in the command? – chrisjlee Jul 25 '11 at 17:10
  • Glad to help out! :) – Sean C. Jul 25 '11 at 17:24
  • 3
    Shouldn't that be rm -r? Plain old rm won't remove directories. Also, I'd recommend the -prune switch to find here: rm -r already deletes all subdirectories, so there's no need to traverse them. – Ilmari Karonen Jul 25 '11 at 19:17
  • find . -type d -iname .svn -print0 | xargs -0 rm -rf – InquilineKea Sep 18 '11 at 19:37
shopt -s globstar
rm -r **/.svn

Most versions of find have a delete action:

$ find /path/in/question -type d -name .svn -delete

Make sure you run it without the delete and look over the results first!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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