首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为dpkg -S定义文件名搜索模式?

如何为dpkg -S定义文件名搜索模式?
EN

Ask Ubuntu用户
提问于 2021-02-06 16:07:48
回答 1查看 348关注 0票数 1

man dpkg在没有给出filename-search-pattern的定义的情况下这么说。

代码语言:javascript
复制
              -S, --search filename-search-pattern...
                  Search for a filename from installed packages.

例如,下面的输出令人困惑。为什么通过移除前导"/",查询字符串不必以结果字符串结尾。

谁能给出filename-search-pattern的定义,这样我才能确切地知道如何使用dpkg -S进行搜索?

代码语言:javascript
复制
$ 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
EN

回答 1

Ask Ubuntu用户

发布于 2021-02-06 16:17:30

-S选项dpkg实际上是一个dpkg-query操作,如man dpkgACTIONS部分所指出的:

代码语言:javascript
复制
   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手册页,您应该找到以下描述:

代码语言:javascript
复制
   -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.
票数 1
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1314155

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档