Annoying svn directories… zap them up!

Posted on: January 21, 2011 Posted by: John Huh Comments: 1

Annoying svn directories… zap them up!

Remove all .svn folders recursively:


rm -rf `find . -type d -name .svn`


Some may have _svn folders instead of .svn, so use it accordingly.

1 people reacted on this

  1. Consider using the following command instead:

    find . -name .svn -print0 | xargs -0 rm -rf

    Using the inline backtics “` some command` ” is ok as long as there are not too many results. If there are too many results, you could get a “argument list too long” error, depending on the buffer size of your shell. Buffer sizes are pretty huge these days but better to be safe than sorry.
    Using the pipe “|” will use standard IO. “-print0” will print the full file name on the standard output, followed by a null character (instead of the new-line character that “-print” uses). This allows file names that contain newlines or other types of white space to be correctly interpreted by programs that process the find output. This option corresponds to the “-0” option of xargs.
    xargs will take the output of the find and execute the command “rm -rf” for each entry. the “-0” option for xargs indicates that the input items are terminated by a null character instead of by whitespace, and the quotes and backslash are not special (every character is taken literally).

    Conclusion, doing the remove command this way will avoid potential problems with filenames containing spaces and will also avoid the “argument list too long” error.

Comments are closed.