Is there a way to print the name of only those packages that consists of certain keywords in their description?

Specifically, I am looking for packages that does not contains php in the description.

Something like -

apt-cache search --full 'php' | grep -e '^Package :'

will print packages with php in their description.

However, I want to negate the result.

  • why not grep -E '[^php]' Commented Jan 6, 2018 at 14:38
  • 1
    It is not clear what you are asking for , did you need to exclude just the package description? or you need to print only one package without description ?
    – GAD3R
    Commented Jan 6, 2018 at 14:53
  • Try apt-cache search --names-only '[^.*php.*]' | grep -Ev 'php' for package names only, or apt-cache search --full '[^.*php.*]' | grep -Ev 'php' for full package details. Commented Jan 6, 2018 at 15:01
  • I have posted an answer , please correct me if I misunderstood the question.
    – GAD3R
    Commented Jan 6, 2018 at 15:28
  • 1
    @GAD3R yes, you misunderstood. As written in the question, I am looking for all packageS ( not a single package ). Also, the packageS should not have the keyword php in their full desciption. GeorgeUdosen is close, yet it does not print all the package names. Commented Jan 6, 2018 at 17:22

1 Answer 1


Two ways I used to achieve this are:

  1. For only package names:

    apt-cache pkgnames | grep -iv '.*php.*'
  2. With full package description:

    apt-cache pkgnames | grep -iv '.*php.*' | xargs -L 1 apt-cache search --full

More information:

  • grep -iv '.*php.*': neagtes results for ones containing foo-php-bar

  • xargs -L 1 apt-cache search --full: passes the grep result to apt-cache comand to print full package descriptions.

Note: The last command spues out a lot of stuff.

  • Can you please describe the second command? What is '[^.*php.*]' doing here? Commented Jan 6, 2018 at 18:38
  • It does the same thing as the first command but this time the full package description for non-php packages are returned. Commented Jan 6, 2018 at 18:39
  • As written in the question, I am looking for packages that does not contain the word php. According to your solution, it looks like, the command return packages that has the word php and then you negate the word php through grep. It doesnt make much sense. Commented Jan 11, 2018 at 8:25
  • What sense are we talking here, or better, insist on a particular solution. I see you used grep in yours so why the makes no sense? Commented Jan 11, 2018 at 9:22
  • see, the question is - if it is possible to print all the packages that DOES NOT CONTAIN the word "php" in their package name as well as description? But your solution is broken, because it is looking for packages that CONTAINS the word php. Quote - [^.*php.*]: targets names like foo-php-bar, foophpbar, etc. The ^.* is regex for the line begins with foo. My use of grep is to just list the lines with the word Package. The use of grep in my example has nothing to do with listing packages related to php or !php. Commented Jan 19, 2018 at 12:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .