为什么 apt-cache search 有错误输出?

为什么 apt-cache search 有错误输出?
root@ubuntu:~# apt-cache search -n ^linux- |grep -v ^linux-
busybox-syslogd - Provides syslogd and klogd using busybox
initramfs-tools - generic modular initramfs generator (automation)
rsyslog - reliable system and kernel logging daemon
dracut - dracut is an event driven initramfs infrastructure
inetutils-syslogd - system logging daemon
socklog-run - system and kernel logging services
syslog-ng-core - Enhanced system logging daemon (core)
tiny-initramfs - Minimalistic initramfs implementation (automation)

答案1

答案似乎是即使加上 --names-only,该apt-cache search命令搜索包的提供的包。 从man apt-cache

   search regex...
       search performs a full text search on all available package lists
       for the POSIX regex pattern given, see regex(7). It searches the
       package names and the descriptions for an occurrence of the regular
       expression and prints out the package name and the short
       description, including virtual package names. If --full is given
       then output identical to show is produced for each matched package,
       and if --names-only is given then the long description is not
       searched, only the package name and provided packages are.

我们可以准确地看到搜索匹配的内容,如下所示:

$ apt-cache search --names-only '^linux-' | grep -v '^linux-' |
    while read -r pkg rem; do apt-cache show "$pkg" | grep -H --label="$pkg" '^Provides:'; done
busybox-syslogd:Provides: linux-kernel-log-daemon, system-log-daemon
busybox-syslogd:Provides: linux-kernel-log-daemon, system-log-daemon
busybox-syslogd:Provides: linux-kernel-log-daemon, system-log-daemon
initramfs-tools:Provides: linux-initramfs-tool
initramfs-tools:Provides: linux-initramfs-tool
initramfs-tools:Provides: linux-initramfs-tool
rsyslog:Provides: linux-kernel-log-daemon, system-log-daemon
rsyslog:Provides: linux-kernel-log-daemon, system-log-daemon
dracut:Provides: linux-initramfs-tool
inetutils-syslogd:Provides: linux-kernel-log-daemon, system-log-daemon
socklog-run:Provides: linux-kernel-log-daemon, system-log-daemon
syslog-ng-core:Provides: libsyslog-ng-dev, linux-kernel-log-daemon, syslog-ng-mod-journal, system-log-daemon
tiny-initramfs:Provides: linux-initramfs-tool

相关内容