我希望检查名称中包含字符串'Terminal'的所有包。目前我可以通过发出以下命令来执行此操作:
apt-cache show someterminalpackage
但是,有很多这样的软件包,我希望一次性查看所有软件包的描述。到目前为止,我已尝试使用xargs但我不知道如何提取包的名称,然后在其上发出上述命令。
你知道怎么做吗?
谢谢!
单个apt-get show
的输出格式为:
package-name - abbreivate package info
例如:
mg - microscopic GNU Emacs-style editor
更新:
不严格要求,但我试图在iPhone上运行这些命令。听到拥有越狱iphone(6.x)的人会很棒。
答案 0 :(得分:1)
以这种方式使用apt-cache:
apt-cache search <your string>
答案 1 :(得分:1)
尝试以下命令,
apt-cache search all | awk -F' - ' '{ print $1}' | grep terminal | xargs -I {} apt-cache show {}
答案 2 :(得分:1)
有点粗糙和准备,但这应该做的工作:
apt-cache search terminal | cut -d "-" -f 1 | grep terminal | xargs -I % bash -c 'echo %; apt-cache show %; echo -e "\n"' > terminals.txt
让我打破这个命令:
apt-cache search terminal
:这会在名称或说明中搜索包含字符串'Terminal'的所有包。
| cut -d "-" -f 1
:提取包名称(假设包名中没有连字符)
| grep terminal
:再次使用grep在提取的包名称中搜索“terminal”。
最后,
| xargs -I % bash -c 'echo %; apt-cache show %; echo -e "\n"' > terminals.txt
:在每个软件包名称上运行apt-cache show命令。
这更接近你想要的吗?
仅供参考,在使用6.1.3的JB'ed iPhone上进行测试:)
答案 3 :(得分:0)
合并apt-cache search
和apt-cache show
:
apt-cache show $(apt-cache search <packagename>)
像
apt-cache show $(apt-cache search vim) | less
答案 4 :(得分:0)
如果您确实只想搜索包名称,则需要apt-cache pkgnames
:
apt-cache pkgnames \
| grep -i terminal \
| xargs apt-cache show