2017-03-22 105 views
0

我的代碼有以下問題:wget不終止

下載完成後,腳本不會終止。它似乎在等待更多的網址。


我的代碼:

#!/bin/bash 

cd "$1" 
test=$(wget -qO- "$3" | grep --line-buffered "tarball_url" | cut -d '"' -f4) 

echo test: 
echo $test 
echo ============== 

wget -nd -N -q --trust-server-names --content-disposition -i- ${test} 

$test一個例子:

https://api.github.com/repos/matrixssl/matrixssl/tarball/3-9-1-open https://api.github.com/repos/matrixssl/matrixssl/tarball/3-9-0-open 
+0

'-i-'意味着從標準輸入讀取URL列表。所以它等着你輸入網址。 – Barmar

+0

是的,當我寫這篇文章時,但我該如何終止它? '$ test'包含網址。 –

回答

1

-i指從文件中獲取URL列表,並在完成對文件的手段的使用-從標準輸入中獲取它們。所以它等着你輸入網址。

如果$test包含的網址,你並不需要使用-i,只列出在命令行上的網址:

wget -nd -N -q --trust-server-names --content-disposition $test 
+0

猜猜我誤解了文檔,我以爲只能處理多個URL和'-i' –