1

I'm using dpkg-query -f '${Package}\n' -W "linux-image*" but that doesn't only show what's installed.

2

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.