我正在使用这个小脚本来查找格式错误的图像:
find -name '*.jpg' -exec identify -format "%f\n" {} \; 2>errors.txt
Run Code Online (Sandbox Code Playgroud)
它工作得很好,但现在我需要稍微修改它。我不想将 stderr 转储到 errors.txt,而是想转储触发错误的图像的文件名 (%f)。也就是说,我想要errors.txt 中格式错误的图像文件的列表,而不是列表错误消息。
我尝试添加 || echo "%f" >> errors.txt 到 -exec 部分,但这不起作用。什么是最好的方法来做到这一点?