Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have the following structure:

/.svn
/bla/.svn
/hello/.svn
/bla/bla/bla/.svn
... etc

I want to delete all the .svn folders. How do I do it?

It's NOT:

rm -rf .svn

In windows you use the /s trigger. How do you do it linux?

share|improve this question
add comment

4 Answers 4

Use the command find:

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

{} is the filename, -type d means directories.

Warning: use find and rm together with caution!

share|improve this answer
    
+1 for the warning, find and rm is potentially a very dangerous combination. –  Dom May 25 '10 at 10:03
1  
Will fill your terminal with lots of warnings of "find: '.../.svn': No such file or directory". The directories get removed, but you can avoid the warnings with -depth (see my answer). –  DevSolar May 25 '10 at 11:37
add comment
find . -depth -type d -name .svn -exec rm -rf {} \;

Differences to other solutions already presented:

  • without -depth, the command will attempt to recurse into the .svn directory after it has deleted it, resulting in error messages.

  • without -type d (which limits your search to directories), you would also delete files of the given name. (Most likely you won't have any, but you shouldn't take chances when doing a combination of "find" and "rm".)

share|improve this answer
    
While your -depth addition is very good (+1 from me), I did have the -type d option in my solution. –  Peter Jaric May 25 '10 at 15:00
add comment

If your exact need is to remove .svn directories and not a more general solution for removing specifically named directories, you should consider using svn export:

$ svn export . /tmp/new-dir

This will create a copy of the svn work area in the current directory into a new directory at /tmp/new-dir. You don't need to create the new directory first. Subversion will take care of that for you.

share|improve this answer
add comment
find . -name .svn -exec rm -rf {}\;

Should work for you.
It first finds all folders named .svn Then executing rm -rf for each folder found.

Result:
No more .svn folders

share|improve this answer
    
find: missing argument to `-exec' –  Dennis Williamson May 25 '10 at 13:45
    
That's what happens when you forget the space before \;. –  DevSolar May 26 '10 at 9:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.