2013-08-02 46 views
1

我被我的一位教授推荐给了这个学生。我从未在我的生活中编写过shell脚本。我已经在线阅读了一些关于shell脚本的教程,但就是这样。无论如何,我被要求创建一个脚本,将运行:使用'grep search'的输出作为'yum update'(Shell Script)的输入

find-repos-of-install | grep rpmfusion 

并给出该搜索的输出,将运行yum更新。例如:

find-repos-of-install | grep rpmfusion 

#that gives this output 
libCg-3.1.0013-2.el6.x86_64 from repo rpmfusion-nonfree-updates 
pgplot-5.2.2-34.el6.1.x86_64 from repo rpmfusion-nonfree-updates 
pgplot-devel-5.2.2-34.el6.1.x86_64 from repo rpmfusion-nonfree-updates 

yum update libCg pgplot pgplot-devel 

这就是他想要的脚本。我不是要求任何人为我写出整个剧本,只是试图指引我走向正确的方向。我已经用Java编写了代码,但是这并没有对我有所帮助,shell脚本对我来说仍然看起来很乱。感谢您的任何提示/提示

回答

0

你有如何调用命令两个选项(YUM你的情况)与另一个命令(在你的情况的grep)的输出:一个是做这样的事情:

$ yum update $(find-repos-of-install | grep rpmfusion) 

另一种是使用xargs,像:

$ find-repos-of-install | grep rpmfusion | xargs yum update 
+0

这是伟大的,谢谢。我最终用'$ find -repos-of-install |进行grep rpmfusion | xargs yum update -y' 非常感谢 – user2646245

+0

好,我很高兴我可以帮忙。 – piokuc

相关问题