我有一个以制表符分隔的 url 和目标文件名的列表,urls_to_download.txt
,例如:
first_file.jpg\thttps://www.google.co.il/images/srpr/logo11w.png
/subdir_1/second_file.jpg\thttps://www.google.co.il/images/srpr/logo12w.png
...
last_file.jpg\thttps://www.google.co.il/images/srpr/logo99w.png
我想使用多个连接下载。
我可以这样做,例如:
cat urls_to_download.txt | xargs -n 1 -P 10 wget -nc
我的问题是,如何让文件具有我想要的新名称,以便输出目录具有:
first_file.jpg
/subdir1/second_file.jpg
...
last_file.jpg
最佳答案
我猜这样的东西应该适合你:
#!/bin/bash
while read FILENAME URL; do
wget -nc -O "$FILENAME" "$URL"
done <input.txt
其中 input.txt 是一个文件,其中包含制表符分隔的文件/url 对,每行一个。
关于linux - 并行下载 url 列表并重命名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24731156/