How to download a file into a directory using curl or wget?

at. picture at. · Oct 17, 2013 · Viewed 86.4k times · Source

I know I can use the following 2 commands to download a file:

curl -O example.com/file.zip
wget example.com/file.zip

But I want them to go into a specific directory. So I can do the following:

curl -o mydir/file.zip example.com/file.zip
wget -O mydir/file.zip example.com/file.zip

Is there a way to not have to specify the filename? Something like this:

curl -dir mydir example.com/file.zip

Answer

Kishan picture Kishan · Oct 31, 2013

The following line will download all the files to a directory mentioned by you.

wget -P /home/test www.xyz.com

Here the files will be downloaded to /home/test directory