7

How do you download a series of files with wget like so:

http://www.example.com/index.php?file=1
http://www.example.com/index.php?file=2
http://www.example.com/index.php?file=3
...
http://www.example.com/index.php?file=500
  • 3
    simultaneously or one by one? – hytromo Jan 13 '13 at 13:51
12

wget supports downloading more than a file with a single command. This means that you can take advantage of your shell features like so:

wget http://www.example.com/index.php?file={1..500}

If your URLs are in a file (one URL per line) or on standard input, you can also use wget's -i option.

  • 1
    If the numbers have padding, you can also do it this way: wget http://www.example.com/index.php?file={001..500} – Jeff Olson Jan 22 '17 at 3:12
4

Place all the urls in a file, one url per line. Let's call it file.txt.

Then place the code inside another file:

#!/bin/bash
while read url; do
   wget "$url"
done < file.txt

save the file at the same directory file.txt and execute it through a terminal.

If you would like to download the files simultaneously, then simply add an & after the wget "$url" command (at the same line)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.