Bash:从文件列表中下载文件

sky*_*das 1 bash

我有一个名为files.txt的文件,其中包含我要下载的所有文件.

files.txt

http://file/to/download/IC_0000.tpl
http://file/to/download/IC_0001.tpl
Run Code Online (Sandbox Code Playgroud)

如果我使用

cat files.txt | egrep -v "(^#.*|^$)" | xargs -n 1 wget
Run Code Online (Sandbox Code Playgroud)

所有文件都已下载.

但我不知道如何使用If files.txt只包含没有http的文件

files.txt

IC_0000.tpl
IC_0001.tpl
Run Code Online (Sandbox Code Playgroud)

我只对这个参数"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...
Run Code Online (Sandbox Code Playgroud)

你能帮我吗.

非常感谢.

Max*_*oel 6

只需尝试wget -i files.txt(参见http://www.gnu.org/software/wget/manual/wget.html#Logging-and-Input-File-Options)

如果文件中没有主机,请尝试:

for i in `cat files.txt`; do wget "${HOST}/${i}"; done
Run Code Online (Sandbox Code Playgroud)