![如何查找不属于某种类型的文件?](https://linux22.com/image/42504/%E5%A6%82%E4%BD%95%E6%9F%A5%E6%89%BE%E4%B8%8D%E5%B1%9E%E4%BA%8E%E6%9F%90%E7%A7%8D%E7%B1%BB%E5%9E%8B%E7%9A%84%E6%96%87%E4%BB%B6%EF%BC%9F.png)
我试图找出我的无组织音乐文件夹中的所有不同类型的文件。我一直在尝试这个命令(列出除了我知道的文件类型之外的文件类型):
find zUnorganized/ -not -iname "*.mp3" -and -not -iname "*.flac" -and -not -iname "*.MP3" -and -not -iname "*.wav" -or -not -iname "*.m4a" -and -not -iname "*.jpg"
但这不起作用。我该如何让该命令起作用?有没有办法使用 -regex 来做到这一点?
谢谢!
答案1
您写道(为了清楚起见,添加了多余的括号):
find zUnorganized/ \( -not -iname "*.mp3" -and -not -iname "*.flac" -and -not -iname "*.MP3" -and -not -iname "*.wav" \) \
-or \( -not -iname "*.m4a" -and -not -iname "*.jpg" \)
要么使用-and -not
全文,要么使用or
全文并结束-print
(意思是:对此不执行任何操作,否则对此不执行任何操作,等等,否则打印)。您还需要将搜索限制为常规文件,否则将列出目录。
find zUnorganized/ -type f -not -iname "*.mp3" -and -not -iname "*.flac" -and -not -iname "*.MP3" -and -not -iname "*.wav" -and -not -iname "*.m4a" -and -not -iname "*.jpg"
find zUnorganized/ \! -type f -o \
-iname "*.mp3" -o -iname "*.flac" -o -iname "*.MP3" -o -iname "*.wav" -o -iname "*.m4a" -o -iname "*.jpg" -o \
-print