answerSeeker Asked: 2017-05-15 17:37:56 +0800 CST2017-05-15 17:37:56 +0800 CST 2017-05-15 17:37:56 +0800 CST 如何使用 dpkg-query 仅列出已安装的软件包版本? 772 我正在使用dpkg-query -f '${Package}\n' -W "linux-image*",但这不仅显示已安装的内容。 dpkg 1 个回答 Voted Best Answer muru 2017-05-15T17:43:38+08:002017-05-15T17:43:38+08:00 也打印状态,然后处理输出: $ dpkg-query -f '${Package} ${Status}\n' -W "linux-image*" linux-image unknown ok not-installed linux-image-4.8.0-36-generic install ok installed linux-image-4.8.0-51-generic install ok installed linux-image-extra-4.8.0-36-generic install ok installed linux-image-extra-4.8.0-51-generic install ok installed linux-image-generic-hwe-16.04 install ok installed $ dpkg-query -f '${Package} ${Status}\n' -W "linux-image*" | awk '$NF == "installed"{print $1}' linux-image-4.8.0-36-generic linux-image-4.8.0-51-generic linux-image-extra-4.8.0-36-generic linux-image-extra-4.8.0-51-generic linux-image-generic-hwe-16.04
也打印状态,然后处理输出: