How to download files using cURL?
Downloading files using the cUrL command
The cUrL (Client URL) is a command-line service and a library for sharing files between different systems.
Unix-like operating systems tend to install the curl command function by default as it supports multiple network protocols (However such as HTTP, FTP, SFTP, etc.)
However, When you are downloading files to your system, using the cUrL is a wise option because of its availability, proxy support, HTTP post, etc.
After that Will show you how you can use the curl command to download files from a network.
The simple syntax of downloading a file using the curl command is:
- Collect files to run using the curl run command:
- The curl https://your-domain/file.pdf
- Acquire files using SFTP/ FTP protocol:
- A curl ftp://ftp-your-domain-name/file.tar.gz
- The file name can customize when downloading with the cUrL command, execute:
- curl -o file.pdf https://your-domain-name/long-file-name.pdf
- While using the cUrL command for downloading files, monitor the 301-redirected file and run:
- A curl -L-o file.tgz http://www.cyberciti.biz/long.file.name.tgz
If the cUrL command line does not install by default, follow the method given below:
To install curl on Linux/ Unix
Usually, curl installed in the operating system by default, but what if it doesn’t?
We can install the curl command as follows:
We can verify the cUrL command’s installation and its current version by using this command:
- $curl ––version
Downloading file using the cUrL
To download a file from a web server, we use:
Therefore, In the above syntax –output or -o allows the user to change or rename the downloaded file.
If the user doesn’t provide the specific name to the downloaded file, Similarly the cUrL will display it on the output screen.
- We can also use this command to download a file:
curl https://www.example.com/sticker.txt
Therefore, with the above cUrL, Similarly, you can download any file from any web server easily.
After the file is successfully downloaded, this screen will be shown:
This information will displays on our screens after downloading a text file from a web server.
- % Total Total size of the recently downloaded file (if written).
- % Received a Total number of bytes that recently download.
- Xferd % Total number of bytes that recently upload.
- Average Dload According to the number of bytes per second, Similarly it is the normal transmission speed of the downloaded file.
- Speed Upload According to the number of bytes per second, it is the normal transmission speed of the uploaded file.
- Time Total According to the hours, minutes, and seconds system, it is known as the estimated time to complete the transfer.
- Time Spent: According to the hours, minutes, and seconds system, it is known as the time spent since the beginning of the transmission.
- Time Left According to the hours, minutes, and seconds system, it is known as the estimated time left to complete the transfer.
- Current Speed According to the number of bytes per second, it shows the normal transmission speed in five seconds. The earliest five seconds of data transmission concentrated in a shorter period.