Score:-2

Why does apt-cache search have wrong output?

au flag
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)
hr flag
I don't know why this is getting downvoted - it seems that even with `--names-only` and proper quoting of `'^linux'` to eliminate possible shell globbing, it returns such results
muru avatar
us flag
@steeldriver probably because it says in the manpage: "It searches the package names and **the descriptions** for an occurrence of the regular expression". If OP got far enough to know `apt-cache search` uses regexes, well...
maP1E bluE avatar
au flag
@muru I always use apt search before, apt said it does not have a stable CLI interface so I tried apt-cache search and I didn't expect that names-only behave differently
guiverc avatar
cn flag
Please provide a question... Your "question" is just a paste without any description or actual question. Depending on device or browser used to read this site, the title text may not be viewable when the page is opened & your question is read - your question being just a paste without any explanation, thus making no sense.
Score:2
hr flag

The answer seems to be that even with the addition of --names-only, the apt-cache search command searches the packages' provided packages. From 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.

We can see exactly what the search is matching as follows:

$ 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
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.