bash - 输出 exiv2 的特定行?
问题描述
使用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
解决方案
尝试这个 -
exiv2 -ps ~/filelocation/filename.jpg |
sed -n '/Image size/{ s/^.*: //; p; }'
sed-n
禁止默认输出。
/pattern/
逐行匹配。
{...}
包装要对匹配的行执行的操作脚本。
s/^.*: //;
剥离前导字符串。
p;
打印值。
推荐阅读
- angular - 带有路由的角度导航栏中的问题
- java - Spring Boot 项目不在 Gradle 本地存储库上运行
- assembly - 为什么我在火星上得到“无效的程序计数器值”?
- javascript - react-map-gl中的动画geojson位置
- mysql - MySQL Sakila DB,获取类别列表并计算出现次数最多的演员
- python - 如何将熊猫数据框保存到分区的 JSON 中
- asp.net-core - asp.net 核心身份服务器 4 仅接受请求的三个自定义域之一
- ios - iOS 中的 Flutter_root 未显示
- reactjs - TypeError:无法读取未定义的属性“searchField”
- python - Python中的对数似然和梯度函数实现