Adam Bien's Weblog

Thursday Sep 24, 2009

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

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

Found it here


[my tweets]  Rss My book: Real World Java EE - Rethinking Best Practices

Kommentare:

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.)

Gesendet von Laszlo Kishalmi am September 24, 2009 at 10:28 AM CEST #

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

Gesendet von Wolfgang Stöcher am September 24, 2009 at 10:44 AM CEST #

Oder ohne das krypitsche exec:

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

Gesendet von Daniel Gerber am September 24, 2009 at 11:00 AM CEST #

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

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

Gesendet von Andrew Phillips am September 24, 2009 at 03:08 PM CEST #

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

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

Gesendet von Niels am September 24, 2009 at 09:09 PM CEST #

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

Gesendet von Jonathan Hawkes am September 25, 2009 at 02:21 AM CEST #

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

Gesendet von timo am September 25, 2009 at 11:20 AM 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.

Gesendet von Claudio Miranda am September 30, 2009 at 05: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>

Gesendet von Claudio Miranda am September 30, 2009 at 05:47 AM CEST #

@Claudio,

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

thanks for your measurements!,

adam

Gesendet von Adam Bien am September 30, 2009 at 09:30 AM CEST #

Why bother with find if you can just type:

rm -f *.svn

??

Gesendet von sharkie am October 04, 2009 at 12:04 AM CEST #

Senden Sie einen Kommentar:
  • HTML Syntax: Ausgeschaltet
Interviews/About
My Recent Book
Java One 2009
CommunityOne East N.Y.C
JavaONE 2008 Interview
Search
...the last 150 posts
...the last 10 comments
greenfire.dev.java.net
Links
my.netbeans.org
Visitors
License