I am trying to write a shell script that uses wget
to download files in bulk from urls that follow a certain numeric pattern.
Understandably, the url from the user input must contain the variable $i
.
dl.sh http://some/url/$i/some/url 1 9
This yields repeated result from the final loop because $i
will be expanded before passing down into the loop.
http://some/url/9/some/url
http://some/url/9/some/url
...
http://some/url/9/some/url
Is there a workaround to get this shell script working?
Source Code:
#!/bin/bash
# dl.sh url | index_from | index_to
for i in $(seq $2 $3)
do
echo ${1} # replace with wget for actual download.
done
Expected Result:
http://some/url/1/some/url
http://some/url/2/some/url
http://some/url/3/some/url
...
http://some/url/9/some/url