dpkg -S 的文件名搜索模式是如何定义的?

dpkg -S 的文件名搜索模式是如何定义的?

man dpkg以下内容未提供 的定义filename-search-pattern

              -S, --search filename-search-pattern...
                  Search for a filename from installed packages.

例如,以下输出令人困惑。为什么通过删除前导“/”,查询字符串不必在结果字符串中结束。

有人可以提供一个定义,filename-search-pattern以便我能够准确地知道如何进行dpkg -S搜索吗?

$ dpkg -S /bin/ls
coreutils: /bin/ls
$ dpkg -S bin/ls
kmod: /sbin/lsmod
pciutils: /usr/bin/lspci
util-linux: /bin/lsblk
util-linux: /usr/bin/lsns
usbutils: /usr/bin/lsusb
e2fsprogs: /usr/bin/lsattr
util-linux: /usr/bin/lsmem
util-linux: /usr/bin/lslogins
initramfs-tools-core: /usr/bin/lsinitramfs
util-linux: /usr/bin/lsipc
kmod: /bin/lsmod
util-linux: /usr/bin/lslocks
gnupg-utils: /usr/bin/lspgpot
lsof: /usr/bin/lsof
coreutils: /bin/ls
util-linux: /usr/bin/lscpu
klibc-utils: /usr/lib/klibc/bin/ls
lshw: /usr/bin/lshw
lsb-release: /usr/bin/lsb_release

答案1

-S的选择实际上dpkg是一种行动,正如的部分dpkg-query所述:ACTIONSman dpkg

   dpkg-query actions
          See dpkg-query(1)  for  more  information  about  the  following
          actions.

          -l, --list package-name-pattern...
              List packages matching given pattern.
          -s, --status package-name...
              Report status of specified package.
          -L, --listfiles package-name...
              List files installed to your system from package-name.
          -S, --search filename-search-pattern...
              Search for a filename from installed packages.
          -p, --print-avail package-name...
              Display details about package-name, as found in
              /var/lib/dpkg/available. Users of APT-based frontends
              should use apt-cache show package-name instead.

如果您按照指示参考dpkg-query手册页,您应该会发现以下描述:

   -S, --search filename-search-pattern...
          Search  for  packages  that own files corresponding to the given
          pattern.  Standard shell wildcard characters can be used in  the
          pattern,  where  asterisk (*) and question mark (?) will match a
          slash, and blackslash (\) will be used as an escape character.

          If the first character in the filename-search-pattern is none of
          ‘*[?/’  then it will be considered a substring match and will be
          implicitly surrounded by ‘*’ (as in  *filename-search-pattern*).
          If  the  subsequent  string contains any of ‘*[?\’, then it will
          handled like a glob pattern, otherwise any trailing ‘/’ or  ‘/.’
          will be removed and a literal path lookup will be performed.

          This  command  will  not  list extra files created by maintainer
          scripts, nor will it list alternatives.

相关内容