How to remove all .svn directories from my application directories

前端 未结 11 2545
臣服心动
臣服心动 2020-12-04 04:26

One of the missions of an export tool I have in my application, is to clean all .svn directories from my application directory tree. I am looking for a recursiv

相关标签:
11条回答
  • 2020-12-04 04:58

    If you don't like to see a lot of

    find: `./.svn': No such file or directory
    

    warnings, then use the -depth switch:

    find . -depth -name .svn -exec rm -fr {} \;
    
    0 讨论(0)
  • 2020-12-04 05:00

    Try this:

    find . -name .svn -exec rm -v {} \;
    

    Read more about the find command at developerWorks.

    0 讨论(0)
  • 2020-12-04 05:02

    Try this:

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

    Before running a command like that, I often like to run this first:

    find . -name .svn -exec ls '{}' \;
    
    0 讨论(0)
  • 2020-12-04 05:05

    In Windows, you can use the following registry script to add "Delete SVN Folders" to your right click context menu. Run it on any directory containing those pesky files.

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
    @="Delete SVN Folders"
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
    @="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""
    
    0 讨论(0)
  • 2020-12-04 05:09

    No need for pipes, xargs, exec, or anything:

    find . -name .svn -delete
    

    Edit: Just kidding, evidently -delete calls unlinkat() under the hood, so it behaves like unlink or rmdir and will refuse to operate on directories containing files.

    0 讨论(0)
  • 2020-12-04 05:09

    You almost had it. If you want to pass the output of a command as parameters to another one, you'll need to use xargs. Adding -print0 makes sure the script can handle paths with whitespace:

    find . -type d -name .svn -print0|xargs -0 rm -rf
    
    0 讨论(0)
提交回复
热议问题