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.
如果某些目录包含 .png 图像,我想删除它们,同时忽略不包含的目录。
我需要使用命令行(我正在使用 MinGW)。
我想一个解决方案将包含rm并定位一个目录,如果它包含*.png. 如何才能做到这一点?
rm
*.png
find -type f -name "*.png" -printf "%h\0" | uniq -z | xargs -0 rm -rf
像这样的东西可能会起作用:
#!/bin/bash shopt -s globstar ls **/*.png | while read f; do dirname "$f" done | sort -uz | xargs -0 rm -rf