![命令查看 Slackware 中安装的软件包总数?](https://linux22.com/image/105583/%E5%91%BD%E4%BB%A4%E6%9F%A5%E7%9C%8B%20Slackware%20%E4%B8%AD%E5%AE%89%E8%A3%85%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%8C%85%E6%80%BB%E6%95%B0%EF%BC%9F.png)
我需要显示总数,但我只找到了列出已安装软件包的命令:
ls -l /var/log/packages/
答案1
使用wc -l
将打印总行数。使用管道将您的ls
内容放入其中
ls /var/log/packages | wc -l
这将为您提供 /var/log/packages 中安装的软件包总数。我在命令中省略的原因-l
是因为在大多数情况下,它将在目录列表的顶部打印总块计数,这将有助于您的结束行计数。
答案2
根据 中的以下评论,从而不是installpkg
获取有关已安装软件包的信息可能更适合未来:/var/lib/pkgtools/packages/
/var/log/packages
# Mon Jun 4 21:17:58 UTC 2018
# Migrate the package database and directories from /var/log to
# /var/lib/pkgtools. /var/log was never a good place for this data, as it is
# considered by many to be a directory that could be wiped to free up some
# space.
截至撰写本文时,它看起来像是/var/log/packages
符号链接,/var/lib/pkgtools/packages/
因此目前仍然有效,但尚不清楚此链接是否被设计为临时或永久,这意味着完全绕过该链接可能是最安全的。
lrwxrwxrwx 1 root root 24 Jun 14 2022 /var/log/packages -> ../lib/pkgtools/packages/