Command Line – How to List All Packages in a Repository Section

command linepackage-managementsynaptic

In Synaptic, one can list packages by section. For example, in the image below all packages of the "Amateur Radio (universe)" section are listed.

How can I get such a list (edit: with package description) at the command line?

I need a raw list; a terminal application like aptitude will not do.

synaptic

Best Answer

Well, though you say you don't want to use aptitude because of the output, you need to know that you can modify it to get what you like:

aptitude -F'|%p|%d|' search '?section(hamradio)'

The trick is in the -F switch that modifies the output format. %p means package. This also outputs when package has various architectures (ie amd64 vs i386), and %d which outputs the description. You can personalize the search pattern even more to for example not installed packages:

aptitude -F'|%p|%d|' search '?section(hamradio) !~i'

where ~i means installed and the ! is a not, so it reads as "not (!) installed (~i)", or if you only want the ones that are available to your architecture:

aptitude -F'|%p|%d|' search '?section(hamradio) ~r native'

~r being ?architecture() which matches the architecture of the package and native which lists only the ones that have the same architecture as the system, the equivalent to dpkg --print-architecture.

The previous line can therefore be written even more concisely as:

aptitude -F'|%p|%d|' search '~s hamradio ~r native'