列出以特定单词开头的所有包的名称

Pen*_*CSC 6 package-management command-line apt

假设我想安装所有的ubuntu-wallpapers包,所以我会在终端输入以下内容:

sudo apt install ubuntu-wallpapers*
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用获得相同的效果

dpkg --set-selections < ./pkgs.txt
Run Code Online (Sandbox Code Playgroud)

问题是,这种方法不支持文件中的*通配符 pkgs.txt

我能够使用

apt-cache search ^ubuntu-wallpapers
Run Code Online (Sandbox Code Playgroud)

但我也得到了描述。有没有办法只获取包名称,以便我可以将输出重定向到pkgs.txt文件?

Byt*_*der 7

您可以使用apt-cache pkgnames来仅列出以特定前缀开头的所有包的名称:

$ apt-cache pkgnames ubuntu-wallpaper
ubuntu-wallpapers-karmic
ubuntu-wallpapers-vivid
ubuntu-wallpapers-maverick
ubuntu-wallpapers-utopic
ubuntu-wallpapers-wily
ubuntu-wallpapers-quantal
ubuntu-wallpapers-raring
ubuntu-wallpapers-precise
ubuntu-wallpapers-lucid
ubuntu-wallpapers-natty
ubuntu-wallpapers
ubuntu-wallpapers-trusty
ubuntu-wallpapers-oneiric
ubuntu-wallpapers-saucy
ubuntu-wallpapers-xenial
Run Code Online (Sandbox Code Playgroud)

查看man apt-cache更多信息。

或者,您可以apt-cache search通过管道处理输出并仅显示第一列,例如通过以下命令之一或任何类似的命令: