我有multiarch
启用,当我运行时debtags search
,我得到很多重复的结果。
$ debtags search 'works-with-format::man' | head
docbook-to-man - converter from DocBook SGML into roff man macros
docbook-to-man:i386 - converter from DocBook SGML into roff man macros
docbook-utils - Convert DocBook files to other formats (HTML, RTF, PS, man, PDF)
docbook2x - Converts DocBook/XML documents into man pages and TeXinfo
docbook2x:i386 - Converts DocBook/XML documents into man pages and TeXinfo
doclifter - Convert troff to DocBook
dwww - Read all on-line documentation with a WWW browser
dwww:i386 - Read all on-line documentation with a WWW browser
ebook-speaker - eBook reader that reads aloud in a synthetic voice
ebook-speaker:i386 - eBook reader that reads aloud in a synthetic voice
有一个解决方法,使用grep
:
$ debtags search 'works-with-format::man' | grep -v ':i386 - ' | head
docbook-to-man - converter from DocBook SGML into roff man macros
docbook-utils - Convert DocBook files to other formats (HTML, RTF, PS, man, PDF)
docbook2x - Converts DocBook/XML documents into man pages and TeXinfo
doclifter - Convert troff to DocBook
dwww - Read all on-line documentation with a WWW browser
ebook-speaker - eBook reader that reads aloud in a synthetic voice
git-man - fast, scalable, distributed revision control system (manual pages)
gman - small man(1) front-end for X
gmanedit - GTK+ man pages editor
gnulib - GNU Portability Library
这假设该字符串:i386 -
没有出现在任何包描述中,这有点黑客行为。有没有更好的办法?
答案1
debtags search 'works-with-format::man' | awk 'BEGIN { FS="[: ]" } ! ($1 in seen) { print; seen[$1]=1 }'
这将记住看到的包(在seen
数组的索引中),无论架构如何(因此使用空格和:
分隔符),并且如果已经看到则不会再次打印它们。因此,它还将显示仅存在于 i386 中而不存在于默认 (amd64) 体系结构中的包(例如:zsnes:i386
标记为hardware::emulation
不存在zsnes
(ie zsnes:amd64
))。因为没有显示显式架构的包首先出现(在债务标签预排序算法中......),所以除非需要,否则无需担心显示额外的内容:i386
。
更新:如所希望的,将独立脚本文件中的相同 awk 脚本放入 /usr/local/bin/debtagsfilter 并包含此内容
#!/usr/bin/awk -f
BEGIN {
FS="[: ]"
}
! ($1 in seen) {
print
seen[$1]=1
}
并通过 ( ) 使其可执行,chmod a+rx /usr/local/bin/filterdebtags
例如可以用于:debtags search 'works-with-format::man' | filterdebtags
或者,如果首选债务标签的“新”版本/usr/local/bin/debtagswithfilter
(从而回退到sh
调用的脚本语言):
#!/bin/sh
debtags "$@" | awk '
BEGIN {
FS="[: ]"
}
! ($1 in seen) {
print
seen[$1]=1
}
'
比较(我得到普通的双精度数,可能是因为多个存储库源):
$ debtags search 'hardware::emulation'
[...]
xtrs - emulator for TRS-80 Model I/III/4/4P computers
xtrs:i386 - emulator for TRS-80 Model I/III/4/4P computers
yabause - beautiful and under-rated Saturn emulator
yabause - beautiful and under-rated Saturn emulator
yabause-gtk - beautiful and under-rated Saturn emulator - Gtk port
yabause-gtk - beautiful and under-rated Saturn emulator - Gtk port
yabause-gtk:i386 - beautiful and under-rated Saturn emulator - Gtk port
yabause-gtk:i386 - beautiful and under-rated Saturn emulator - Gtk port
yabause-qt - beautiful and under-rated Saturn emulator - Qt port
yabause-qt - beautiful and under-rated Saturn emulator - Qt port
yabause-qt:i386 - beautiful and under-rated Saturn emulator - Qt port
yabause-qt:i386 - beautiful and under-rated Saturn emulator - Qt port
zsnes:i386 - Emulator of the Super Nintendo Entertainment System
和:
$ debtagswithfilter search 'hardware::emulation'
[...]
xtrs - emulator for TRS-80 Model I/III/4/4P computers
yabause - beautiful and under-rated Saturn emulator
yabause-gtk - beautiful and under-rated Saturn emulator - Gtk port
yabause-qt - beautiful and under-rated Saturn emulator - Qt port
zsnes:i386 - Emulator of the Super Nintendo Entertainment System
它也适用于更复杂的搜索请求:
$ debtagswithfilter search 'works-with-format::tex && interface::text-mode'
asymptote - script-based vector graphics language inspired by MetaPost
auctex - integrated document editing environment for TeX etc.
axiom-tex - General purpose computer algebra system: style file for TeX
bibcursed - Interactive program to edit BibTeX bibliographies
chktex - Finds typographic errors in LaTeX
fweb - literate-programming tool for C/C++/Fortran/Ratfor
groff - GNU troff text-formatting system
vim-latexsuite - view, edit and compile LaTeX documents from within Vim
yatex - Yet Another TeX mode for Emacs