Recursively Remove SVN files

findrmsubversion

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 {} \+

Best Answer

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

EDIT

  • -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
Related Question