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 How can I use dpkg-query to list only installed version of a package? 772 I'm using dpkg-query -f '${Package}\n' -W "linux-image*" but that doesn't only show what's installed. dpkg 1 Answers Voted Best Answer muru 2017-05-15T17:43:38+08:002017-05-15T17:43:38+08:00 Print the status as well, then process the output: $ 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
Print the status as well, then process the output: