rpm -q -> 只查询描述

rpm -q -> query only the descripton

我可以使用

查询有关 rpm 包的信息
rpm -qi <rpm-package-name>

查询结果示例:

tfaa004:/sm/bin # rpm -qi expect-5.45-16.1.3.i586
Name        : expect
Version     : 5.45
Release     : 16.1.3
Architecture: i586
Install Date: Di 27 Jun 2017 15:31:08 CEST
Group       : Development/Languages/Tcl
Size        : 674166
License     : SUSE-Public-Domain
Signature   : RSA/SHA256, Do 25 Sep 2014 11:42:26 CEST, Key ID b88b2fd43dbdc284
Source RPM  : expect-5.45-16.1.3.src.rpm
Build Date  : Do 25 Sep 2014 11:42:16 CEST
Build Host  : cloud120
Relocations : (not relocatable)
Packager    : http://bugs.opensuse.org
Vendor      : openSUSE
URL         : http://expect.nist.gov
Summary     : A Tool for Automating Interactive Programs
Description :
Expect is a tool primarily for automating interactive applications,
such as telnet, ftp, passwd, fsck, rlogin, tip, and more.  Expect
really makes this stuff trivial.  Expect is also useful for testing
these applications.  It is described in many books, articles, papers,
and FAQs.  There is an entire book on it available from O'Reilly.
Distribution: openSUSE 13.2

但我只想查询描述。那可能吗? 这样做的原因是我想在 C++ 程序中处理此信息(描述)(我使用 popen() 执行此操作)。

也许是这样的:

rpm -qi -Description expect-5.45-16.1.3.i586

[编辑 openSUSE rpm 输出]:

rpm -qi package_name | sed '1,/Description/d;/分布/,$d'

这只会打印“描述”和“分发”之间的行

[以下命令适用于 RHEL 发行版]

我不相信“rpm”实用程序有一个标志来只打印出“描述”字段,但它就像使用管道一样简单:)

你可以这样做:

rpm -qi openssh-server-5.3p1-104.el6.x86_64 | awk '/说明/, 0'

这将在找到模式“Description”后打印每一行。

或者,如果您更倾向于使用“grep”:

rpm -qi openssh-server-5.3p1-104.el6.x86_64 | grep -A20 'Description'

“-A n”标志告诉 grep 在找到模式后打印 n 行。

***编辑:您也可以使用“sed”:

rpm -qi openssh-server-5.3p1-104.el6.x86_64 | sed -e '1,/描述/d'

希望对您有所帮助。

这是正确的解决方案:

rpm -q --queryformat '%{DESCRIPTION}\n'  expect-5.45-16.1.3.i586