linux - 查找并删除所有不包含某些文件类型的目录

标签 linux bash find

这是我目前所拥有的,它可以工作,但它会抛出一个错误,我不确定为什么:

$ find . -mindepth 1 -type d '!' -exec sh -c 'ls -1 "{}" | egrep -i -q "\.(mp4|avi|mkv)"' \; -print -exec rm -r {} \;
./test
find: `./test': No such file or directory

最佳答案

试试这个命令 找到。 -mindepth 1 -type f | egrep -v "\.(mp4|avi|mkv)$"| xargs rm -i

关于linux - 查找并删除所有不包含某些文件类型的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38810469/

相关文章:

linux - 安装 Open edX 平台 : Production and Developer Instances

php - 设置要在一天的 cron 作业的特定时间事件上执行的 url

c++ - 如何编写写入/var/log/myapp 目录的 C/C++ 应用程序?

php - 以下网址 : curl couldn't resolve host 'GET'

linux - 如何在查找命令中使用 `file | grep <string>`?

java - 如何将 javac 的输出重定向回调用程序

linux - 在 bash 中按给定的时间间隔重新执行命令

bash - cURL 将 JSON 作为 x-www-form-urlencoded 发送

linux - Bash-在多个目录上执行相同的命令

python - 在 python 中查找并替换文本文件