5 cURL Files Download Examples

cURL is an open source command line tool and library for transferring data from remote systems. cURL support wide range of protocols like FILE, FTP, FTPS,HTTP, HTTPS, SCP, SFTP and many more. 5 cURL Files Download Examples.
This article will help you to how to download remote files using cURL with examples.

1. Download Single File

Use following command to download a single file from remote server using HTTP protocol. The following example will download latest.tar.gz from remote server and save in current directory with same name.
$ curl -O http://wordpress.org/latest.tar.gz   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                  Dload  Upload   Total   Spent    Left  Speed 100   178  100   178    0    0    239      0 --:--:-- --:--:-- --:--:--   239 

2. Download File and Save with Other Name

Use following command to download a single file from remote server and save at specified location with specified name on local disk. The following example will download latest.tar.gz from remote server and save in /tmp/ directory with name wp.tar.gz.
$ curl -o /tmp/wp.tar.gz  http://wordpress.org/latest.tar.gz   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                  Dload  Upload   Total   Spent    Left  Speed 100   178  100   178    0    0    212      0 --:--:-- --:--:-- --:--:--   212 

3. Download Multiple Files

Use following command to download files from multiple files from multiple remote servers using HTTP protocol. The following example will download latest.tar.gz and latest.zip from remote servers and save in current directory with same names.
$ curl -O http://wordpress.org/latest.tar.gz -O http://wordpress.org/latest.zip   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                  Dload  Upload   Total   Spent    Left  Speed 100   178  100   178    0    0    202      0 --:--:-- --:--:-- --:--:--   202 100   178  100   178    0    0    387      0 --:--:-- --:--:-- --:--:--   387 

4. Download File with HTTP/FTP Authentication

If remote files are behind authentication and required username and password to download files. Use following examples to download files.
Download files from ftp server with ftp login credentials
$ curl -u ftpuser:ftppasswd -O ftp://ftp.example.com/file.zip 
Download files from http server with http login credentials.
$ curl -u username:password -O http://wordpress.org/latest.tar.gz 

5. Download Files Behind Proxy Server

If your connection required proxy server to download remote files. Use following examples to download files through proxy server. Use -x following by proxy_server:port .
$ curl -x 192.168.0.100:3128 -L -O  http://wordpress.org/latest.tar.gz    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                  Dload  Upload   Total   Spent    Left  Speed 100   178  100   178    0    0    435      0 --:--:-- --:--:-- --:--:--   435 100 6373k  100 6373k    0    0   116k      0  0:00:54  0:00:54 --:--:--  102k 

Thanks for Visit Here

Comments