using apt-cache search
I am learning how to use apt. When I do an apt-cache search git
to see all packages matching git, I see a bunch of packages whose
descriptions have nothing to do with git. Why is this so and
how can I fix it? (Ubuntu 12.04.2 LTS).
Also, why is the search functionality found in a command that has "cache" in its name? What does search functionality have to do with caches?
Thanks.
Solution 1:
If you want only to search by name, use the --names-only
argument. For more information, read the man apt-cache
, it would be useful.
Solution 2:
When you perform an apt-cache search <package name>
command, you are performing a query against the information stored on your local machine for available packages. This is the cache from your "subscribed" repositories. That is, the command is performing a query against the repositories that you have set up in USC(Ubuntu Software Center) or Synaptic.
According to the apt-cache
man page, /etc/apt/sources.list
is the location to fetch information from in the query. There are a couple of additional locations for other types of package information. See man apt-cache
for more details.
Essentially, running apt-cache search git
will return all instances of available packages containing the word sequence "git" in the package name, as well as in the package description.
For example, this means that any package that may contain the word sequence "git" in it, like the word "digital", in its description will also be returned as a result. Please note the bold in the previous sentence.
If you are only interested in packages that are specifically concerned with git - the source control manager, you will need to restrict your query to using a regular expression in order to make the search results more restrictive.
For example:
sudo apt-cache search ^git$
will return results that explicitly contain only the phrase "git" in the package name.
For example:
sudo apt-cache search ^git$
git - fast, scalable, distributed revision control system
The command:
sudo apt-cache search ^git
will return results for packages which begin with the phrase "git":
For example:
sudo apt-cache search ^git
git - fast, scalable, distributed revision control system
git-core - fast, scalable, distributed revision control system (obsolete)
git-doc - fast, scalable, distributed revision control system (documentation)
git-man - fast, scalable, distributed revision control system (manual pages)
gitk - fast, scalable, distributed revision control system (revision tree visualizer)
easygit - git for mere mortals
gforge-plugin-scmgit - Git plugin for FusionForge (transitional package)
git-all - fast, scalable, distributed revision control system (all subpackages)
git-annex - manage files with git, without checking their contents into git
git-arch - fast, scalable, distributed revision control system (arch interoperability)
...
That said, you will need to tune your queries of the package cache to be more specific to your interest. Hope this helps.