我被一位教授推荐给这个学生工作。我从来没有在我的生活中编写过shell脚本。我已经在线阅读了一些有关shell脚本的教程,但就是这样。无论如何,我被要求创建一个将运行的脚本:
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 :(得分:0)
你有两个方法可以调用命令(在你的情况下是yum)和另一个命令的输出(在你的情况下是grep):一个是做类似的事情:
$ yum update $(find-repos-of-install | grep rpmfusion)
另一个是使用xargs
,例如:
$ find-repos-of-install | grep rpmfusion | xargs yum update