apt-cache
给出一行摘要:
$ 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
并没有:
$ 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
,它记录在哪里?
答案1
您需要告诉apt
使用自定义格式,并为其指定自定义格式:
$ 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
输出是${Package} - ${Description}
,而apt search
的默认短格式字符串是${color:highlight}${Package}${color:neutral}/${Origin} ${Version} ${Architecture}${ }${apt:Status}\n ${Description}\n
。
答案2
我能得到的最接近的是:
$ 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
我找到的配置选项文件(Ubuntu 20.04)是:
/usr/share/doc/apt/examples/configure-index
有这个选项
apt::cmd::format "<STRING>";
但我无法让它发挥作用(能力)也找不到如何使用它的示例。也许有人可以从这里拿走它。