When I want to download a file in a folder in Linux via wget I use the following:
JavaScript
x
wget -P /patch/to/folder/ http://example.com/file.zip
Now let’s say I want to download several files into the same folder and my urls are:
JavaScript
http://example.com/file1.zip
http://example.com/file2.zip
http://example.com/file3.zip
How can I achieve this in one with command in the same folder /patch/to/folder/?
Thank you.
Advertisement
Answer
You can just append more URLs to your command:
JavaScript
wget -P /patch/to/folder/ http://example.com/file1.zip http://example.com/file2.zip http://example.com/file3.zip
If they only differ by number, you can have bash brace expansion automatically generate all the arguments before wget
runs:
JavaScript
wget -P /patch/to/folder/ http://example.com/file{1..3}.zip
You can tell that this is possible from the invocation synopsis in man wget
, where the ...
is a convention that means it can accept multiple at a time:
JavaScript
SYNOPSIS
wget [option] [URL]