Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am wanting to search for every package that has a description of PDF. How do I do that with apt-cache or is there a different command I can use?

share|improve this question
    
Do you really want to search just the description as you say, or do you also want to search the package names? You write "only descriptions", but is it a dealbreaker? 'apt-cache search pdf | grep -i pdf' only gives 9 more hits than limiting the search to only the description. –  Daniel Andersson Mar 21 '12 at 7:58

2 Answers 2

up vote 2 down vote accepted

You can use:

apt-cache search 'PDF' | grep ' - .*PDF'

This will give you only entries that have 'PDF' in their description.

share|improve this answer
    
Thanks. What does the hyphen do i.e. - .? –  PeanutsMonkey Mar 21 '12 at 7:15
    
You see the output from apt-cache search? grep will print only the lines that matches the (in this case simplified) regular expression '` - .*PDF`', which means that it only prints lines containing the pattern "[space][hyphen][space][any character]{the preceding match 0 or more times}PDF". ' - ' is what separates the package name from its description, so this will first print all packages that have "PDF" in its name OR its description, and then pick out only the latter. –  Daniel Andersson Mar 21 '12 at 7:50
    
There are, however, multiple (16 on my system) packages whose description contain "pdf" with small letters. The above command should be changed to "... | grep -i ' - .*pdf' to make the search case insensitive. –  Daniel Andersson Mar 21 '12 at 7:54

To use apt-cache you need to massage the output by yourself. Using aptitude, you can do

aptitude search '?description(pdf~))'

which does exactly what you want. See the aptitude reference manual (install aptitude-doc-en and look in /use/share/doc/aptitude/ or use a web interface directly) for more info regarding its search syntax.

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.