Aaron Johnson Now with 50% less caffeine!

Posted
6 April 2007 @ 9pm

Tagged
Systems Administration

command line script to delete .svn files / folders

I wrote this down in my notes.txt awhile back where it’ll eventually get lost, putting it here so that I search it from google:

find ./ -name ".svn" | xargs rm -Rf

source: http://www.rickhurst.co.uk/category/linux/


11 Comments

Posted by
Dale Fraser
7 April 2007 @ 3am

Doesn’t work.

C:\>find ./ -name “.svn” | xargs rm -Rf
‘xargs’ is not recognized as an internal or external command,
operable program or batch file.

C:\> :P


Posted by
Tim Elsner
7 April 2007 @ 5am

Great hint. Also, for those that don’t know, you can checkout a clean copy of the code directly from subversion by using “svn export”. This leave you with a perfect copy of the code, without the .svn folders.


Posted by
A.J. Wright
7 April 2007 @ 9am

Here is a slightly more efficient way of doing the same thing:

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

When you use -exec find will execute the command for every result returned via the find query into the argument {}

Another useful command is to only perform and operation on files that have not been added or modified. You can do this like so:

svn status | grep ? | awk ‘{print $2}’ | xargs rm -rf

This would remove any file that has been added to the repository.

Breaking it down

svn status will return results like this:

? foo
M build/projects/Community.iml
M build/build.properties

Piping it through grep ? will give you:

? foo

Awk can be used to print out the column we want that is what the print $2 part of the awk command is for.

foo

finally pass the results to xargs rm

Hope this is interesting.

cheers,
A.J.


Posted by
rob
7 April 2007 @ 11am

I use:

find ./ -name “.svn” -exec rm -rf {} \;

which does the same thing with out the pipe (not that that matters though)


Posted by
ऋतेश का बलोग
21 April 2007 @ 1am

Command to delete .svn files / folders [Linux Only]…

find ./ -name “.svn” | xargs rm -Rffind ./ -name “.svn” | xargs rm -Rf

Ref…


Posted by
michaelr
13 October 2007 @ 11pm

worked for me in Cygwin


[...] How to remove .svn files [...]



Posted by
Craig McQueen
10 June 2009 @ 2pm

I had trouble with these if the pathnames contained spaces. This seemed to work however:

find ./ -name “.svn” -exec rm -rf “{}” \;


Posted by
Dave
6 August 2009 @ 6pm

Could also do

find ./ -name “*.svn” -delete


Posted by
Arjen Heidinga
17 September 2009 @ 3am

How about svn export? :P


Leave a Comment

Links: 4-3-2007 Links: 4-6-2007