How To Remove All .svn Files With An One-Liner (Bash)

find . -name ".svn" -exec rm -rf {} \;

Found it here

Comments:

Or if you wish to keep your working copy:

svn export . <other directory>

(It's not widely known, that svn can export form working copy which is fast and does not require to be connected to the server.)

Posted by Laszlo Kishalmi on September 24, 2009 at 12:28 PM CEST #

on Windows:
for /D /R . %f in (.svn) do ( rmdir /S /Q "%f" )

Posted by Wolfgang Stöcher on September 24, 2009 at 12:44 PM CEST #

Oder ohne das krypitsche exec:

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

Posted by Daniel Gerber on September 24, 2009 at 01:00 PM CEST #

A colleague of mine adds: "And this variation even prints what was thrown away"

find . -name ".svn" -exec rm -rf '{}' \; -print

Posted by Andrew Phillips on September 24, 2009 at 05:08 PM CEST #

I think you have to escape the { and } as well (for the bash):

find . -name ".svn" -exec rm -rf \{\} \;

Posted by Niels on September 24, 2009 at 11:09 PM CEST #

or...
rm -fr $(find . -name '*.svn')

Posted by Jonathan Hawkes on September 25, 2009 at 04:21 AM CEST #

and and for the lazy guys :)
http://robwilkerson.org/2008/02/19/deleting-svn-folders/

Posted by timo on September 25, 2009 at 01:20 PM CEST #

A optimized version, replace the \; by +

find . -name ".svn" -exec rm -rf {} +

The \; signal maked the find command fork the "rm" command for each occurrence.
The + signal, groups all the occurrences, then invoke the rm command only once.

Posted by Claudio Miranda on September 30, 2009 at 07:42 AM CEST #

A teste performed on a directory which contained 2767 .svn directories.

<pre>
$ time find v3-1 -name .svn -type d -exec rm -rf {} \;
real 0m9.889s
user 0m3.364s
sys 0m3.680s

$ time find v3-2 -name .svn -type d -exec rm -rf {} +

real 0m1.599s
user 0m0.244s
sys 0m1.344s
</pre>

Posted by Claudio Miranda on September 30, 2009 at 07:47 AM CEST #

@Claudio,

thanks! - now we can move to mercurial even faster :-),

thanks for your measurements!,

adam

Posted by Adam Bien on September 30, 2009 at 11:30 AM CEST #

Why bother with find if you can just type:

rm -f *.svn

??

Posted by sharkie on October 04, 2009 at 02:04 AM CEST #

@sharkie Because that doesn't work for what they're trying to do.

"rm -f *.svn" will remove all files with a .svn extension in the current directory.

"find . -type d -name ".svn" | xargs rm -rf" will recursively remove directories with a name of ".svn" in all sub-directories.

The directory is called, ".svn" -- it's not a file extension.

Posted by Scott W on May 07, 2010 at 02:49 PM CEST #

Thanks, this command helped me out.

Posted by Nick on January 12, 2012 at 07:17 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License