首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何有“适当的搜索”给出一行摘要?

如何有“适当的搜索”给出一行摘要?
EN

Unix & Linux用户
提问于 2022-01-17 20:20:46
回答 2查看 245关注 0票数 1

apt-cache给出了一行摘要:

代码语言:javascript
复制
$ apt-cache search conway
golly - Game of Life simulator using hashlife algorithm
libclass-delegator-perl - Perl module for a simple and fast object-oriented delegation
...

但是,apt search没有:

代码语言:javascript
复制
$ apt search conway
Sorting... Done
Full Text Search... Done
golly/impish 3.3-1build1 amd64
  Game of Life simulator using hashlife algorithm
libclass-delegator-perl/impish,impish 0.09-4.1 all
  Perl module for a simple and fast object-oriented delegation
...

有一个apt配置选项使它返回一行摘要,但我不知道它是什么。这个-o选项是什么,它在哪里文档化?

EN

回答 2

Unix & Linux用户

发布于 2022-01-18 06:03:04

您需要告诉apt使用自定义格式,并给它一个自定义格式:

代码语言:javascript
复制
$ apt -o apt::cmd::use-format=1 -o apt::cmd::format='${Package} - ${Description}' search conway
Sorting... Done
Full Text Search... Done
golly - Game of Life simulator using hashlife algorithm
libclass-delegator-perl - Perl module for a simple and fast object-oriented delegation
libmodule-starter-pbp-perl - Perl module to create new perl modules following best practices
libmoosex-followpbp-perl - Moose extension to name your accessors get_foo() and set_foo()
libperl-critic-perl - Perl module to critique code for best practices
libsub-wrappackages-perl - module to wrap subroutines in packages
libtemplate-plugin-lingua-en-inflect-perl - interface to Lingua::EN::Inflect for the Template Toolkit
sagemath-database-conway-polynomials - Database of Conway polynomials

支持的格式“变量”没有文档化(在源代码中甚至有这样的注释);阅读这个apt来源显示它们如下所示:

  • ${db::Status-Abbrev}:状态标志的摘要(B用于已损坏的包,g用于可升级的包,i用于已安装的软件包,-用于其他一切);
  • ${Package}:包名;
  • ${Architecture};封装体系结构;
  • ${installed:Version}:已安装的版本;
  • ${candidate:Version}:候选版本;
  • ${Version}:正在列出的版本;
  • ${Origin}:档案套件;
  • ${apt:Status}:状态字符串(“已安装”、“可升级”、“自动”等);
  • ${color:highlight}:高光的转义代码;
  • ${color:neutral}:转义码返回到“中性”颜色;
  • ${Description}:简短的描述;
  • ${LongDescription}:长篇描述。

匹配apt-cache search‘S输出的格式字符串是${Package} - ${Description},而apt search的默认短格式字符串${color:highlight}${Package}${color:neutral}/${Origin} ${Version} ${Architecture}${ }${apt:Status}\n ${Description}\n

票数 3
EN

Unix & Linux用户

发布于 2022-01-17 22:10:32

我能得到的最接近的是以下内容:

代码语言:javascript
复制
$ apt search -o="apt::cmd::use-format=1" conway
Sorting... Done
Full Text Search... Done
- golly 3.3-1build1 focal Game of Life simulator using hashlife algorithm
- libclass-delegator-perl 0.09-4 focal,focal Perl module for a simple and fast object-oriented delegation
- libmodule-starter-pbp-perl 0.0.3-2 focal,focal Perl module to create new perl modules following best practices
- libmoosex-followpbp-perl 0.05-2 focal,focal Moose extension to name your accessors get_foo() and set_foo()
- libperl-critic-perl 1.138-1 focal,focal Perl module to critique code for best practices
- libsub-wrappackages-perl 2.01-1 focal,focal module to wrap subroutines in packages
- libtemplate-plugin-lingua-en-inflect-perl 0.04-1 focal,focal interface to Lingua::EN::Inflect for the Template Toolkit
- sagemath-database-conway-polynomials 0.5-7 focal,focal Database of Conway polynomials

我在配置选项(Ubuntu20.04)中找到的文件是:

代码语言:javascript
复制
/usr/share/doc/apt/examples/configure-index

有个选择

代码语言:javascript
复制
apt::cmd::format "";

但是我不能让它起作用 (智能)并没有找到如何使用它的例子。也许有人可以从这里拿走它。

票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/686765

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档