Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .