Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wget: read URL from file, add sequence of number to the URL

Tags:

variables

bash

I am reading a file (with URL's) line by line:

#!/bin/bash
while read line
do
    url=$line
    wget $url
    wget $url_{001..005}.jpg
done < $1

For first, I want to download primary url as you see wget $url. After that I want to add to the url sequence of numbers (_001.jpg, _002.jpg, _003.jpg, _004.jpg, _005.jpg):

wget $url_{001..005}.jpg

...but for some reason it's not working.

Sorry, missed out one thing: the url's are like http://xy.com/052914.jpg. Is there any easy way to add _001 before the extension? http://xy.com/052914_001.jpg. Or I have to remove ".jpg" from the file containing URL's then simply add later to the variable?

like image 946
Adrian Avatar asked Sep 13 '25 22:09

Adrian


1 Answers

Another way escaping the underscore char:

wget $url\_{001..005}.jpg
like image 113
Iris G. Avatar answered Sep 15 '25 10:09

Iris G.