2013-08-02 48 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

相關問題