使用 apt-cache 搜索

使用 apt-cache 搜索

我正在学习如何使用 apt。当我执行apt-cache search git 查看所有与 git 匹配的软件包时,我看到一堆描述与 git 无关的软件包。为什么会这样?我该如何修复它?(Ubuntu 12.04.2 LTS)。

另外,为什么名称中包含“cache”的命令中会出现搜索功能?搜索功能与缓存有什么关系?

谢谢。

答案1

如果只想按名称搜索,请使用参数--names-only。有关更多信息,请阅读man apt-cache,它将很有用。

答案2

当您执行apt-cache search <package name>命令时,您正在针对本地计算机上存储的可用软件包信息执行查询。这是来自您“订阅”存储库的缓存。也就是说,该命令正在针对您在 USC(Ubuntu 软件中心)或 Synaptic 中设置的存储库执行查询。

根据apt-cache手册页,/etc/apt/sources.list是查询中获取信息的位置。还有其他几个位置用于获取其他类型的软件包信息。请参阅man apt-cache以了解更多详细信息。

本质上,运行apt-cache search git将返回包名称以及包描述中包含单词序列“git”的所有可用包实例。

例如,这意味着任何可能包含单词序列“git”的包,如单词“digital”,其描述中也将被返回作为结果。请注意上一句中的粗体部分。

如果您只对与 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)
...

也就是说,您需要调整包缓存的查询,使其更符合您的兴趣。希望这能有所帮助。

答案3

这是对你问题的间接回答,但仍然与它相关,因为它与包管理有关。我个人使用 aptitude 而不是 apt-get。aptitude 是突触相当于终端。

寻找,

sudo aptitude search $keyword

其他命令

sudo aptitude install
sudo aptitude update
sudo aptitude upgrade

要安装 aptitude,

sudo apt-get install aptitude

答案4

安装 apt-xapian-index 并在搜索时使用 axi-cache 搜索而不是 apt--cache。您将获得更好的结果

相关内容