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


This entry was posted in Systems Administration. Bookmark the permalink.

25 Responses to command line script to delete .svn files / folders

  1. Dale Fraser says:

    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

  2. Tim Elsner says:

    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.

  3. A.J. Wright says:

    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/

    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.


    finally pass the results to xargs rm

    Hope this is interesting.


    • swapnil says:

      hey, can you suggest any way that will help me to find a particular file and delete it via command prompt.

  4. rob says:

    I use:

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

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

  5. Pingback: ऋतेश का बलोग

  6. michaelr says:

    worked for me in Cygwin

  7. Pingback: Scott Motte » Blog Archive » Removing .svn files and folders

  8. Pingback: Aaron Johnson – command line script to delete .svn files / folders | Bookmarks

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

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

  10. Dave says:

    Could also do

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

  11. Hacker says:


    It still helps! Even 2 years later ;)

  12. Pingback: Blog de Bastien Paul » Unix command to delete .svn folders

  13. veelck says:

    Still helps, even 4 years later :)


  14. Upul Abayagunawardhana says:

    Thanks for this. Very helpful!

  15. Pingback: Delete .svn files and folders - Juancho Rossi

  16. Alex says:

    Very helpful even now!

  17. jay mabazza says:

    worked! thanks!

  18. Luis says:

    I found another choice. Just to share it with all of you:

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

    The key is the grave accent quotes in this case. It worked in a split second.

  19. Gabriel Mathias says:

    Still helps, even 6 years later


  20. xr09 says:

    If the paths contain spaces then this will do:

    find ./ -name ".svn" -print0 | xargs -0 rm

    but again as many people already posted the pipeless version is nicer:

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

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>