Recursively removing .svn directories
I’ve found on numerous occasions that I needed to recursively remove all the .svn directories from a checked out copy of my code. I’ve always just googled it and found the command quickly that way since I don’t know how to do it off the top of my head. I consider myself pretty fluent in Unix systems but there are just some commands that I’ve never really dug into much. Here is what google turns up:
How does that really work? Well, we first have to understand how the first command works before the pipe:
If you omit the ‘-print0′ it simply dumps all the .svn directories it finds recursively from the current directory. The ‘-print0′ works in conjunction with the ‘-0′ option inside the pipe. The ‘-print0′ basically doesn’t return a new line but rather formats the output in a way that you can process each element of the results using the ‘xargs’ command.
That command really won’t do much unless you pass it something, usually through the pipe. So, ‘xargs’ just takes the output from the find command and process each element of the results by passing it to the command specified. In this case it is ‘rm -rf’. So combined we have ‘find’ getting all the results and piping the whole thing to ‘xargs’ and ‘xargs’ passes each element of that set to a ‘rm -rf’ command. Its fairly simple when you break it down.

August 17th, 2007 at 12:57 am
Do you have to work on an already checked out version? Because otherwise “svn export” should solve your problem ;-)
August 17th, 2007 at 1:02 am
Thanks for the tip. That would require access to the server hosting the repository wouldn’t it?
August 17th, 2007 at 12:04 pm
yes, it would