Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
    
possible duplicate of Find package name using terminal –  nux May 20 at 14:14
3  
@nux I see absolutely no commonalities between your suggested duplicate and my question! I also did a proper search here before asking. –  Gin Gordon May 20 at 15:15

3 Answers 3

up vote 3 down vote accepted

Well, trough you say you don't want to use aptitude because 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 match the architecture of the package and native which list only the ones that has the same architecture than the system, the equivalent to dpkg --print-architecture.

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

aptitude -F'|%p|%d|' search '~s hamradio ~r native'
share|improve this answer
    
Very elegant, especially with -F'|%p|%d|'. However, would it be possible not to list the :i386 packages by adding a !-expression to the search string? –  Gin Gordon May 28 at 17:24
1  
@GinGordon yeah, just add ~r native to the search terms. ~r being ?architecture which match the architecture of the package and native which list only the ones that has the same architecture than the system, the equivalent to dpkg --print-architecture. BTW, you wanted the list with package description? –  Braiam May 28 at 17:35
    
Great! And yes, I have edited the question to include package description. Please, edit your answer accordingly and you deservingly will receive my best answer vote for being the most concise. –  Gin Gordon May 28 at 17:53
    
@GinGordon check it out. –  Braiam May 28 at 17:59
1  
@GinGordon if you install the aptitude-doc package and navigate to /usr/share/doc/aptitude/html/en/index.html with your browser you will find in file:///usr/share/doc/aptitude/html/en/ch02s04s05.html all the nasty perks. –  Braiam May 28 at 18:41

Make sure the dctrl-toolsInstall dctrl-tools package is installed. It provides useful commands for searching the apt and dpkg package lists. To get a full description of all packages from a particular section that are installable with apt, run

grep-aptavail -F Section hamradio

This will show the full package metadata for every package in the hamradio section. If all you want to see are the package names, run

grep-aptavail -n -F Section -s Package hamradio

If your system is set up for multiarch, the same package may show up more than once in this listing if it is built for more than one architecture. So to refine this further, use either

grep-aptavail -n -F Section -s Package hamradio | sort | uniq

or

grep-aptavail -n -F Section -s Package hamradio | sort -u

to sort the package list and remove duplicate packages with the same name.

Note that you will have to use the actual name of the section, which is different from the "human-readable" name that Synaptic shows in its GUI. For example, the searches above use the section name hamradio instead of the string "Amateur Radio" shown in Synaptic.

See the man page for grep-aptavail for a full description of all options and some examples.

share|improve this answer

More fields on a single line, with arbitrary separator

The following one-liner will print all unique package names of a repository section, together with their description, each on a single line. All fields are separated by a pipe character, i.e. ready for conversion into a Markdown pipe table. The resulting table can be found on my web site.

grep-aptavail -n -s Package,Description -F Section hamradio |paste -sd '||\n' |sed 's:^:|:' |sort -u
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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