Curl command file utility supports for downloading and uploading files. Curl is useful for many works with system administration, web development for calling web services, etc. In this tutorial, we are providing 5 frequently used curl commands to download files from remote servers.
1. Simple curl command to download file
To download a file using curl use the following syntax. -O is used for saving files on the local system with the same name on the remote system.
curl -O http://example.com/download/myfile.zip
2. Curl download file and save with different name
You can also save the downloaded file with a different name on the local machine. Use
-o followed by the new file name to download and save files with a different name.
curl -o localname.zip http://example.com/download/myfile.zip
3. Curl to Download Multiple Files
Curl also provides an option to download multiple files simultaneously. To download multiple files at once using the following syntax. All files will be saved with original file names.
curl -O http://example.com/myfile.zip -O http://example.com/myfile2.zip
4. Use Login Credential with Curl Download
Some of the remote resources required authentication to download any file. Curl also allows you to provide authentication details to authorize requests. You can pass login credentials using
-u option for HTTP for FTP requests, like:
curl -u user:password -O http://example.com/myfile.zip
curl -u ftpuser:ftppassword -O ftp://ftp.example.com/myfile.zip
5. Curl download file via proxy
If the server file is only available through a proxy server, or you want to use a proxy for downloading files, Use -x followed by a proxy address and port to download the file via a proxy server.
curl -x "my.proxy.com:3128" -O http://example.net/myfile.zip
Curl is a useful utility to create GET, POST, HEADER, and many other requests to remote servers. Even it is helpful for downloading remote files quickly like wget. This tutorial 5 examples of the curl commands for downloading files from a remote server.