当你执行
apt-cache search <package name>
命令时,你正在对存储在本地机器上的可用软件包信息进行查询。这是来自你“订阅”的软件源的缓存。也就是说,该命令是针对你在USC(Ubuntu软件中心)或Synaptic中设置的软件源进行查询。
根据
apt-cache
手册页面,
/etc/apt/sources.list
是查询中获取信息的位置。还有一些其他类型的软件包信息的位置。请参阅
man apt-cache
以获取更多详细信息。
基本上,运行
apt-cache search git
将返回所有包含软件包名称和描述中包含单词序列“git”的可用软件包实例。
例如,这意味着任何可能在其中包含单词序列“git”的软件包,比如描述中的单词“di
gital”,也将作为结果返回。请注意前一句中的加粗字体。
如果你只对与Git - 源代码管理工具相关的软件包感兴趣,你需要使用正则表达式限制查询,以使搜索结果更加严格。
例如:
```
sudo apt-cache search ^git$
```
将返回仅包含短语“git”在软件包名称中的结果。
例如:
sudo apt-cache search ^git$
git - fast, scalable, distributed revision control system
命令:
sudo apt-cache search ^git
将返回以词组“git”开头的软件包结果:
例如:
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)
...
话虽如此,您需要调整软件包缓存的查询以更具体地符合您的兴趣。希望这对您有所帮助。
apt-cache search ^git$
只会返回包名中包含"git"的结果。"git-man"(从您发布的第二个输出中)也包含"git",这是我不理解的地方。请问插入符号和美元符号的意思是什么?我知道插入符号表示“以...开头”,但这与您发布的第二个输出(^git
的输出)相矛盾,因为它返回了"easygit" =)。 - Alaa Ali^
表示以git
开头的包和描述。好的,第二个输出已经理解了。那么^git$
返回什么呢?以git
开头的包和...? - Alaa Aliapt-cache search ^git$
将返回具体的git软件包。apt-cache search ^git
将返回以短语“git”开头的软件包,但不太具体。 - Kevin Bowenapt-cache search ^git | grep --color git
来增强你的命令。 - georg