AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 905928
Accepted
guettli
guettli
Asked: 2018-04-05 02:24:22 +0800 CST2018-04-05 02:24:22 +0800 CST 2018-04-05 02:24:22 +0800 CST

所有软件包的可排序列表 (dpkg)

  • 772

我想在使用dpkg.

到目前为止,我使用dpkg -l.

但它有一个缺点:对结果进行排序没有意义。

头:

root@aptguettler:~# LANG=C dpkg-query -l| sort | head
+++-===========================================================-=================================================-============-================================================================================
Desired=Unknown/Install/Remove/Purge/Hold
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
ii  a11y-profile-manager-indicator                              0.1.10-0ubuntu3                                   amd64        Accessibility Profile Manager - Unity desktop indicator

尾巴:

root@aptguettler:~# LANG=C dpkg-query -l| sort | tail
rc  texlive-publishers-doc                                      2015.20160320-1                                   all          TeX Live: Documentation files for texlive-publishers
rc  texlive-science                                             2015.20160320-1                                   all          TeX Live: Natural and computer sciences
rc  texlive-science-doc                                         2015.20160320-1                                   all          TeX Live: Documentation files for texlive-science
rc  tpconfig                                                    3.1.3-15                                          amd64        touchpad device configuration utility
rc  ttf-indic-fonts-core                                        1:0.5.14ubuntu1                                   all          Core collection of free fonts for languages of India
rc  ttf-punjabi-fonts                                           1:0.5.14ubuntu1                                   all          Free TrueType fonts for the Punjabi language
rc  unity-lens-friends                                          0.1.3+14.04.20140317-0ubuntu1                     amd64        Friends scope for unity
rc  webaccounts-extension-common                                0.5-0ubuntu2.14.04.1                              amd64        Ubuntu Online Accounts browser extension - common files
rc  xfonts-mathml                                               6ubuntu1                                          all          Type1 Symbol font for MathML
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend

我通过etckeeper(Related question with answer log hwinfo output with etckeeper)保留了这个输出的历史。

以下是我想改进的地方:

  • ascii-art 线条不好。应该被删除。
  • 前两个字符(例如ii)应删除或出现在末尾。

基于 rpm 的系统rpm -qa完全符合我的需要。

dpkg
  • 1 1 个回答
  • 391 Views

1 个回答

  • Voted
  1. Best Answer
    Broco
    2018-04-05T03:21:22+08:002018-04-05T03:21:22+08:00

    尝试

    dpkg --get-selections | grep -v deinstall
    

    如果您需要输出中数据包的确切版本,您可以执行以下操作:

    dpkg -l | grep '^ii' | awk '{print $2 "\t" $3}'
    

    这仅打印第 2 列和第 3 列。这也仅列出已安装的软件包,没有卸载或其他。

    编辑:另一个选项是 dpkg-query:

    dpkg-query --show --showformat='${Package} ${Version}  ${Architecture} ${db:Status-Abbrev} \n'
    

    其中--showformat(或-f)定义了你想要显示的列,在这种情况下,包名称、版本和架构以及最后的简短状态(例如“ii”和“rc”),“\n”是换行符。

    顺便说一句,“ii”定义了已安装的包,“rc”是卸载的包,这就是我使用 grep 和 awk 过滤掉卸载的包的原因。

    如果您喜欢,也可以像这样添加列宽:

    dpkg-query --show --showformat='${Package;-50} ${Version;-40}  ${Architecture;-5} ${db:Status-Abbrev} \n'
    

    负列宽意味着方向是左,正意味着右。

    但要小心,因为如果宽度小于包名称中的字符数,包名称将被缩短。

    我不确定您需要该列表的目的是什么。如果您只想拥有一个可读性好的列表,那么 awk 或其他命令没有任何问题,如果您想在另一台机器上安装软件的“备份”,dpkg --get-selections(没有任何管道)是去,见https://wiki.debian.org/ListInstalledPackages

    • 4

相关问题

  • 在 Amazon Linux 上安装 Debian 软件包工具 (dpkg-buildpackage)?

  • DPKG Equivs 问题

  • 将 rpm 命令转换为 dpkg

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve