使用exiv2,您可以在终端中输出图像信息。然而,它输出了几行信息:
exiv2 -ps ~/filelocation/filename.jpg输出如下所示:
File name : ~/filelocation/filename.jpg
File size : 12345 Bytes
MIME type : image/jpeg
Image size : 800 x 600
~/filelocation/filename.jpg: No Exif data found in the file如何命令终端只输出图像大小数据?
我真正想要的是:
exiv2 -ps ~/filelocation/filename.jpg [some command here]输出:
800 x 600发布于 2018-06-26 17:30:33
试试这个-
exiv2 -ps ~/filelocation/filename.jpg |
sed -n '/Image size/{ s/^.*: //; p; }'sed的-n抑制默认输出。
/pattern/逐行匹配。
{...}封装了一个动作脚本,以便在匹配的行上执行。
s/^.*: //;剥去前导字符串。
p;打印值。
https://stackoverflow.com/questions/51048364
复制相似问题