4

When I want to search for a package named z, aptitude finds packages that contain z in the package name (same as LIKE in SQL), so aptitude finds a lot of packages.

How can I search for packages named z?

3 Answers 3

4

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 
2
  • 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 :) Commented Apr 2, 2013 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. Commented Jan 9, 2014 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)" 
-1

Answer: apt search -n z

-n stands for --names-only, which obviously should be the default.

1
  • This does not seem to be using aptitude. It also does not solve the issue of searching for exact matches. Commented May 12, 2022 at 18:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.