问题原文
原帖链接 · Amandasaurus · CC BY-SA 4.0
On Debian/Ubuntu, dpkg can show me packages, include the version and what's installed (e.g. dpkg -l postgresql\*). But that shows all packages that it knows about, whether installed or not.
Is it possible to make dpkg only show me the installed packages?
I've tried on dpkg v1.21.8 on Debian testing/bookworm, and v1.19.0.5 on Ubuntu 18.04 bionic
社区高分解答
原帖链接 · Tilman Schmidt · CC BY-SA 4.0
dpkg itself cannot do it, but it's possible to achieve it with a combination of dpkg-query and awk:
dpkg-query -W -f '${db:Status-Status} ${Package}\n' 'linux-image-[0-9]*' | awk '$1 != "not-installed" {print}'
See this question over on Ask Ubuntu: https://askubuntu.com/questions/1330078/limit-output-of-dpkg-query-w-to-installed-packages
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
