I want to find a list of all packages with the Priority: field set to Required. These are packages that are normally installed on every system, however I've recently discovered that they aren't necessarily installed for foreign architectures using multiarch. What's the best way to find these packages?
With aptitude you can do that type of search.
Note that aptitude is no longer installed by default on newer Ubuntu releases, and its man-page is incomplete; you'll find the full documentation as
/usr/share/doc/aptitude/README
(Disclaimer: this answer uses a low level system tool to solve the requested problem, not aptitude. But since aptitude relies on dpkg services, it might still be useful.)
You can make use of
dpkg-query
combined withgrep
:dpkg-query
lists all packages, when no package name is specified.-W
or (--show
) allows for listing packages using a specified output format.--showformat='formatstring'
syntax. The string consists of:${Package}
to display the package name.\t
to display a Tab character as field separator.${Priority}
to display the package priority.\n
to display a newline character at the end of each line.Since a sample output without
grep
looks like this:The
grep
command displays only lines containing the „required” word at the end, i.e. the packages with Priority: required.