使用shell脚本进行多线程下载

syn*_*pse 5 bash wget curl

假设我有一个包含大量 URL 的文件,我想使用任意数量的进程并行下载它们。我怎样才能用 bash 做到这一点?

小智 10

看看man xargs

-P max-procs --max-procs=max-procs

         Run  up  to max-procs processes at a time; the default is 1.  If
         max-procs is 0, xargs will run as many processes as possible  at
         a  time.
Run Code Online (Sandbox Code Playgroud)

解决方案:

xargs -P 20 -n 1 wget -nv <urs.txt
Run Code Online (Sandbox Code Playgroud)