rpm --qf 命令
1. 环境准备:
sudo apt-get install rpm (Ubuntu系统)
wget ftp://rpmfind.net/linux/fedora-secondary/development/rawhide/Everything/ppc64le/os/Packages/y/yum-3.4.3-511.fc26.noarch.rpm(下载个rpm包供测试)
2. 使用方法:
查询所有信息:
dill@ubuntu-vm:~/Downloads$ rpm -qpi yum-3.4.3-511.fc26.noarch.rpm
warning: yum-3.4.3-511.fc26.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 64dab85d: NOKEY
Name : yum
Version : 3.4.3
Release : 511.fc26
Architecture: noarch
Install Date: (not installed)
Group : System Environment/Base
Size : 5873606
License : GPLv2+
Signature : RSA/SHA256, 2016年09月15日 星期四 22时14分17秒, Key ID 812a6b4b64dab85d
Source RPM : yum-3.4.3-511.fc26.src.rpm
Build Date : 2016年09月13日 星期二 22时22分16秒
Build Host : buildhw-12.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager : Fedora Project
Vendor : Fedora Project
URL : http://yum.baseurl.org/
Summary : RPM package installer/updater/manager
Description :Yum is a utility that can check for and automatically download and
install updated RPM packages. Dependencies are obtained and downloaded
automatically, prompting the user for permission as necessary.
查询特定字段信息:
dill@ubuntu-vm:~/Downloads$ rpm -qp --qf '{"name":"%{Name}","version":"%{Version}"}
' yum-3.4.3-511.fc26.noarch.rpm
{"name":"yum","version":"3.4.3"}
同理可以取得Release、Size等信息,只需要在--qf 中添加相应选项。
"{}" 用于显示,可以省略
"name" 用于更改字段名
可以控制输出格式:
dill@ubuntu-vm:~/Downloads$ rpm -qp --qf "%{NAME}-%{VERSION}-%{RELEASE}
" yum-3.4.3-511.fc26.noarch.rpm
yum-3.4.3-511.fc26