1

我的一位教授向我推荐了这份学生工作。我一生中从未编写过 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 脚本对我来说仍然像胡言乱语。感谢您的任何提示/提示

4

1 回答 1

0

您有两种选择如何使用另一个命令的输出(在您的情况下为 grep)调用命令(在您的情况下为 yum):一个是执行以下操作:

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

另一种是使用xargs,例如:

$ find-repos-of-install | grep rpmfusion | xargs yum update
于 2013-08-02T14:30:45.840 回答