Downloading multiple files in parallel with changed names

Downloading multiple files in parallel with changed names

I'm writing bash script and don’t know how to solve my problem.

I want to to download multiple files at the same time , but ... I want to save the files under modified names.

I have a variable with urls.

example.com/aaa.txt
example.com/ooo/bbbbbb.txt 
example.info/c.txt 

The order of the URL is important.

After downloading I want:

1.txt
2.txt
3.txt

I tested parallel and wget. But I do not know how to change the file names.

PS: Limit of 5 simultaneous downloads.

答案1

what i really need is to see a sample of your variable of URLs. but nonetheless, here's the basis of what i'm thinking:

 #!/usr/bin/bash

 end=$(wc -l URLs.txt | sed 's/\ .*//g')
 x=1

 while read URL; do

         until [ $x -eq $end ]; do

                wget $URL --output-document=$x.txt
                x=$(($x+1))

         done

 done < URLs.txt

i'll edit it if you have more infomation, but at the moment i've set it up so that it reads URLs.txt which has to be one URL per line and in the same directory

相关内容