rpm -q - >仅查询描述

问题描述 投票:1回答:2

我可以查询有关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
c++ linux command-line rpm
2个回答
4
投票

这是正确的解决方案:

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

1
投票

[编译openSUSE rpm输出]:

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

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

[以下cmds适用于RHEL发行版]

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

你可以这样做:

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

在找到“描述”模式后,将打印每一行。

或者,如果你更倾向于使用“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,/Description/ d'

希望这可以帮助。

© www.soinside.com 2019 - 2024. All rights reserved.