I've found a bazillion references to get a list of the installed packages, but how can I print a single list of all known packages with their "package state" (not-installed
, installed
, half-installed
etc. as defined by dpkg
) in a shell, ideally like this:
awk not-installed
bash installed
cc half-installed
[...]
dpkg --get-selections
and dpkg --list
only lists installed packages.
dpkg --get-selections '.'
does not work.
apt-cache dump
does not print whether packages are installed, and also prints a lot of irrelevant stuff.
I'm using Travis CI, which is running Ubuntu 12.04 LTS Server Edition 64 bit with for example dpkg-query
1.16.1.2.
You want
dpkg-query
;For
dpkg-query
>= 1.17.11:For
dpkg-query
< 1.17.11:#1:
-f '${Package}\t${db:Status-Status}\n'
: When used with the-W
option, specifies the format of the output (seeman dpkg-query
for other options);-W '*'
: lists all the packages matching the pattern*
;#2:
-f '${Package} ${Status}\n'
: When used with the-W
option, specifies the format of the output (seeman dpkg-query
for other options);-W '*'
: lists all the packages matching the pattern*
;awk '{print $1"\t"$4}'
: prints only the first and fourth field;In this case it seems like you want to list the status word, so I picked the
db:Status-Status
virtual field; here are the other virtual fields related to the package status:will show you all the installed, uninstalled and half installed packages. Just grep on the package you want to filter.