1
Using a Bash terminal, how can I have 5 ± 2 concurrent cURL processes downloading at any time in a script, until there aren't any more links?
Pseudocode:
Links = {a.txt, b.txt, c.txt, d.txt ... x.txt, y.txt, z.txt}
Loop URLS in Links
if (less than 5 cURL processes)
cURL URL
else
wait until 1 cURL process stopped
What is the use of the ampersand (&) near "fi"? – MZhQfmpXFz3WZ9h – 2017-04-28T02:57:06.213
Also, shouldn't it be a
-lt
rather than-gt
? – MZhQfmpXFz3WZ9h – 2017-04-28T03:04:52.927The & means put the process in the background. You are welcome to execute the command using $() if thats how you prefer to do it - I wrote this script as a starting point. the -gt is correct because the script is waiting if there is more then 4 processes and only executing the next version when there are no longer more then 4 processes. (IE the logic is, by necessity the opposite to your pseudo-code in this respect). Please note that SU is not a script writing service and when we provide scripts its by way of demonstration of how to proceed, its not cast in stone. – davidgo – 2017-04-28T03:31:24.990