![아키텍처별로 부채 태그 검색 필터링](https://linux55.com/image/130010/%EC%95%84%ED%82%A4%ED%85%8D%EC%B2%98%EB%B3%84%EB%A1%9C%20%EB%B6%80%EC%B1%84%20%ED%83%9C%EA%B7%B8%20%EA%B2%80%EC%83%89%20%ED%95%84%ED%84%B0%EB%A7%81.png)
나는 가지고있다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
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