When I first started my website I discussed some of the options of using the command line / terminal to download content from the internet without using a web browser.
Recently I started looking through some of my partially wrote blog posts / ideas for posts and decided to finish / post them. This evenings post is using wget to download multiple sequentially named files via a quick script that can be run via Bash.

In this example I am using the fantastic Mag Pi magazines PDF directory, which contains PDFs of the Mag Pi magazine – if you like the Raspberry Pi, then you should be reading this magazine.
The PDFs of the magazine are named in the format MagPi??.pdf with the ?? being the issue number. Using a for loop the issues can all be downloaded (to save on bandwidth I’m only downloading issues 50 to 80):
echo “Starting…”
for i in {50..80}
do
wget https://www.raspberrypi.org/magpi-issues/MagPi$i.pdf
done

The $i represents the value of i which starts at 50 and increases one value at a time to 80. The file can be created in a text editor (e.g. Nano) and then saved with the .sh file extension. Then use the command bash filename.sh to run it, e.g. if you saved it as download.sh use bash download.sh to run the script.

And thats it, lots of issues of Mag Pi magazine to enjoy and lots of excellent Raspberry Pi project ideas especially during March’s #MonthOfMaking .
2 thoughts on “Downloading Multiple Files Via Wget (Linux)”
Comments are closed.