Command line to delete matching files and directories recursively

后端 未结 6 1637
-上瘾入骨i
-上瘾入骨i 2020-12-12 14:21

How can I recursively delete all files & directories that match a certain pattern? e.g. remove all the \".svn\" directories and the files they contain?

(Sadly DO

6条回答
  •  抹茶落季
    2020-12-12 14:46

    Something like this may do the trick, but of course be careful with it!

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

    Try something like this first to do a dry run:

    find . -name ".*" -exec echo {} \;
    

    Note that the empty braces get filled in with the file names and the escaped semicolon ends the command that is executed (starting after the "-exec").

提交回复
热议问题