2014-12-06 49 views
0

我有一個名爲files.txt的文件,其中包含我想要下載的所有文件。Bash:從文件列表中下載文件

files.txt

http://file/to/download/IC_0000.tpl 
http://file/to/download/IC_0001.tpl 

如果我使用

cat files.txt | egrep -v "(^#.*|^$)" | xargs -n 1 wget 

所有文件都被下載。

但我不知道怎麼用。如果files.txt只包含文件,而HTTP

files.txt

IC_0000.tpl 
IC_0001.tpl 

我有 「的wget」 僅此放慢參數:

Usage: wget [-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document FILE] 
     [--header 'header: value'] [-Y|--proxy on/off] [-P DIR] 
     [--no-check-certificate] [-U|--user-agent AGENT] [-T SEC] URL... 

請問你能幫助我嗎?

非常感謝。

+0

這些文件是否都具有相同的URL? – Seth 2014-12-06 18:29:29

回答

0

剛剛離開這裏...... 用於MacOSX的

file_name=newMP3List.txt && cur_path=$(pwd) && split -l 50 $file_name PART && find . -name "PART*" -print0 | xargs -0 -I f osascript -e "tell application \"Terminal\" to do script \"cd $cur_path && cat f | while read CMD; do curl -O \\\"\$CMD\\\"; done; rm f;\"" 

for linux

cat newMP3List.txt | while read CMD; do curl -O $CMD; done; 

需要用您的文件名替換newMP3List.txt