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

source: http://www.rickhurst.co.uk/category/linux/

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

18 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/build.properties

    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.

    foo

    finally pass the results to xargs rm

    Hope this is interesting.

    cheers,
    A.J.

  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:

    Thanks!

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

    thanks!

  14. Upul Abayagunawardhana says:

    Thanks for this. Very helpful!

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>