2

When I want to search a package which named 'z', aptitude find packages which contains 'z' in package name same as 'like' in SQL, so aptitude find a lots of packages.

How can I search packages which package named z?

3

The pattern given to an aptitude search is a regex, so you can use that to find exact matches:

aptitude search '^z$'

When you know the exact package name, you are not really "searching". If you want to see if the package is available, you can use apt-cache policy. The aptitude front-end doesn't really have an equivalent to this, but you can do an aptitude show.

apt-cache policy z
aptitude show z
  • I did not think I can use regex. You are right. If I know package name, I should not use aptitude search. Now I think this is a stupid question :p. In fact aptitude show and apt-cache are exactly what I am looking for. Thanks :) – Mesut Tasci Apr 2 '13 at 22:32
  • Thanks for this. The aptitude front end allows your first example regex to get right to the exact package name. There are some situations when this can come in handy, i.e. while selecting multiple packages for installation or removal, for some of which the exact name is known. – snapfractalpop Jan 9 '14 at 18:22
1

If you want to find packages that contain a whole word (e.g. find perl, but not sooperlooper), you can include word boundaries in your search pattern:

$ aptitude search '\bperl\b'

Aptitude also supports a wealth of search terms, as described in the reference manual., which allow you to change where exactly it looks for your pattern. For example, to find a Perl for your system, try:

$ aptitude search "?exact-name(perl) ?architecture(amd64)"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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