Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要删除的文件夹中有许多 EC2 实例。使用-delete不起作用,因为目录不为空。我试图寻找一种方法让 -rmdir -f 工作但没有成功。实例文件夹都是以这样的方式开始的,"i-"这导致我添加"i-*"了这样的通配符,以删除所有以这些字符开头的目录。我怎样才能做到这一点?目录也永远不会为空。
-delete
"i-"
"i-*"
假设您当前的目录是有问题的文件夹,那么:
find . -type d -name 'i-*'
如果这列出了您要删除的目录,则将其更改为:
find . -type d -name 'i-*' -exec rm -r {} \;