Remove all .svn directories
Posted March 11th, 2011 in Linux/Unix/BSD
If you've been using Subversion for revision control and no longer want to use it (for example if you've moved to another revision system like git) there are a whole bunch of .svn directories you'll need to get rid of. This post shows how to remove them from the command line on Unix based systems like Linux and Mac OSX.
find with -delete
This is a nice simple solution that works on Linux but doesn't work on my Mac. It works fine for filenames that don't start with . so I suspect that's the issue. Change to the directory you want to delete the .svn directories from and run this command:
find . -name .svn -delete
find with -exec
This is a slightly more complex command but it will work on both Mac and Linux:
find . -depth -name .svn -exec rm -fr {} \;
The -depth argument is required to prevent find entering the directory that was just deleted and showing error messages like e.g. "find: ./.svn: No such file or directory"
The -exec part runs rm -fr passing the name of the file/directory found where the {} placeholder is. The \; at end terminates the exec command and \ is required to escape it on the command line.
Related posts:
- Using find to locate all zero length files (Thursday, August 4th 2011)
- Subversion Command Line Script to export changed files V2 (Friday, July 9th 2010)
- Subversion Command Line Script to export changed files (Thursday, June 17th 2010)
- Which directory is that bash script in? (Sunday, February 21st 2010)
- Error processing command with SVN on a Samba server from Windows (Sunday, February 15th 2009)
- Installing subversion on CentOS (Sunday, November 30th 2008)

Comments
blog comments powered by Disqus