【发布时间】:2018-06-13 19:59:09
【问题描述】:
我正在寻找一个 Bash 命令,它允许我识别目录中的所有图像,而不管文件扩展名如何。例如,如果一张照片具有 .doc 扩展名,我希望能够使用脚本来识别它。
到目前为止,我有以下内容,但它只返回具有典型文件扩展名的图像。
find . -type f -exec file {} \; | grep -i -o -E '^.+: \w+ image'
【问题讨论】:
-
这对我有用。
find . -maxdepth 1 -type f -exec file {} \; | grep -i -o -E '^.+: \w+ image'返回./pic.doc: PNG image ./test.png: PNG image