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.
apt-cache search ^git$
will only return results that contain "git" in the package name". I don't understand this, because, for examplegit-man
(from the second output you posted) also containsgit
. Can you explain what do the caret and the $ symbols mean? I know that the caret means "begins with", but then this contradicts with the second output you posted (output of^git
), because it's returningeasygit
=). – Alaa Ali Aug 14 '13 at 11:47^
means packages and descriptions that start withgit
. Okay, the second output is understood. So what does^git$
return? Packages that start withgit
and ...? – Alaa Ali Aug 14 '13 at 11:56apt-cache search ^git$
will return, specifically, the git package.apt-cache search ^git
will return packages that begin with the phrase "git" and will be less specific. – Kevin Bowen Aug 14 '13 at 12:24apt-cache search ^git | grep --color git
– georg Nov 04 '15 at 08:27^git$
way suggested seems very handy but it is too narrow as it would exclude, say, "git2" (I know it doesn't exist, but just as an example). – Ivan Nov 26 '15 at 12:46