代码之家  ›  专栏  ›  技术社区  ›  Andre

rpm-q->仅查询描述符

  •  1
  • Andre  · 技术社区  · 7 年前

    我可以通过以下方式查询有关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
    
    2 回复  |  直到 7 年前
        1
  •  4
  •   Andre    7 年前

    这是正确的解决方案:

    rpm -q --queryformat '%{DESCRIPTION}\n'  expect-5.45-16.1.3.i586
    
        2
  •  1
  •   Community CDub    4 年前

    [编辑openSUSE rpm输出]:

    rpm—qi包名称| sed’1,/描述/d/分配/,$d'

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

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

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

    您可以:

    rpm-qi openssh-server-5.3p1-104。el6.x86\U 64 | awk’/描述/,0”

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

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

    rpm-qi openssh-server-5.3p1-104。el6.x86\u 64 | grep-A20“说明”

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

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

    rpm-qi openssh-server-5.3p1-104。el6.x86\u 64 | sed-e“1,/描述/d”

    希望这有帮助。