如何从所有子目录中递归删除具有特定名称的所有文件夹?

时间:2016-02-12 00:13:48

标签: linux search find

以下是一些目录路径的示例

find . -name .svn;

./application/views/scripts/soft/.svn
./application/views/scripts/sitemap/.svn
./application/views/scripts/register/.svn
./application/views/scripts/home/.svn
./application/views/scripts/terms-of-service/.svn
./application/views/scripts/promotions/.svn
./application/views/scripts/test/.svn
./application/views/scripts/privacy-policy/.svn
./application/views/scripts/services/.svn
./application/views/scripts/mobile/.svn
./application/test/.svn
./application/public/.svn

我想立即从当前的根目录中删除所有这些目录中的所有.svn个文件夹。

任何deas?

2 个答案:

答案 0 :(得分:2)

您可以执行(将-type d添加到您的find命令以仅获取文件夹)

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

答案 1 :(得分:1)

find . -name \*.svn -type f -delete