1) How to search for packages matching "word1 or word2" with aptitude?
2) How to search for packages matching "word1 and word2" with aptitude?
On
Take a look at the aptitude search pattern quick reference.
pattern1 | pattern2: Select packages that match pattern1, pattern2, or both.
pattern1 pattern2: Select any package that matches both pattern1 and pattern2.
Since that's a pipe, make sure it's escaped or in a string if you're running aptitude from a shell; it has a special meaning for shells.
This wasn't clear to me from the documentation initially either. In my case, I wanted to search for packages that matched a name and were installed.
Anyway, the key is that each argument is a space separated list of conditions that are AND'd, and each argument is OR'd. So:
Will search for all packages that contain the string
fooand the stringbarWhere as:
Will search for all packages which contain either
fooorbarYou can then combine this with other conditions that aptitude accepts to do things like:
Will list all installed packages that contain the string
pythonin their nameThere are also other ways of doing this. For example: