Syl*_*eau 2 command-line apt bash
我想以类似的方式从命令行使用http://packages.ubuntu.com/的强大功能apt-file search -i来查找提供包含特定模式的文件的包。
我无法使用,apt-file因为我不仅需要搜索我正在运行的版本 (14.04),还需要搜索 14.10 和 15.04。
例如com.canonical.Unity,如果我从命令行运行 14.04,我怎样才能获得所有提供 glib-2.0 模式的包,但对于 14.10?
安装html2text:
sudo apt-get install html2text
Run Code Online (Sandbox Code Playgroud)将以下函数粘贴到您的.bashrc:
apt-file-remote()
{
pattern="$1"
release="$2"
if [ -z "$release" ]; then
release="$(lsb_release -c -s)"
fi
wget "http://packages.ubuntu.com/search?searchon=contents&keywords=$pattern&mode=filename&suite=$release" -qO- |
html2text -width 999 | grep --color=never '^/'
}
Run Code Online (Sandbox Code Playgroud)重新启动 shell 或打开一个新终端
使用模式作为第一个参数运行它,然后是版本代码名称(可选,默认为当前版本):
$ apt-file-remote com.canonical.unity utopic
/etc/dbus-1/system.d/com.canonical.Unity.Greeter.Broadcast.conf unity-greeter-session-broadcast
[...]
/usr/share/glib-2.0/schemas/com.canonical.Unity.Thumbnailer.gschema.xml thumbnailer-service
/usr/share/glib-2.0/schemas/com.canonical.Unity.gschema.xml unity-schemas
/usr/share/glib-2.0/schemas/com.canonical.unity-greeter.gschema.xml unity-greeter
/usr/share/glib-2.0/schemas/com.canonical.unity-gtk-module.gschema.xml unity-gtk-module-common
/usr/share/glib-2.0/schemas/com.canonical.unity.clickscope.gschema.xml unity-scope-click
/usr/share/glib-2.0/schemas/com.canonical.unity.webapps.gschema.xml unity-webapps-service
/var/lib/polkit-1/localauthority/10-vendor.d/com.canonical.unity.webapps.pkla unity-webapps-common
Run Code Online (Sandbox Code Playgroud)
多亏了这个功能,我发现:
/usr/share/glib-2.0/schemas/com.canonical.Unity.Thumbnailer.gschema.xml
Run Code Online (Sandbox Code Playgroud)
仅从 Utopic 开始安装。
笔记:
-width 999默认html2text使用 80 列渲染输出,这可能会将某些名称分成 2 行。apt-file search -i