logo Sahil Singh Rana
Cat
Sahil's Moon.
Command to download file using curl.

Download file using curL

Download File Using Curl Command

curl is a command-line tool used to transfer data from or to a server using various protocols such as HTTP, HTTPS, FTP, and more. Let’s see how we can download file from remote server to our system using the tool.

What is curl?

curl is used in command lines or scripts to transfer data. curl is also used in cars, television sets, routers, printers, audio equipment, mobile phones, tablets, medical devices, settop boxes, computer games, media players and is the Internet transfer engine for thousands of software applications in over twenty billion installations.

curl is used daily by virtually every Internet-using human on the globe.

Taken from official website 🔗

Prerequisites

Before using the curl command, ensure curL is installed in your system:

  1. Operating System: curl is available on most Unix-like operating systems (Linux, macOS) and Windows. Make sure your OS supports curl.
  2. Install: Verify if curl is installed on your system. Open your terminal and type:
    curl --version
    
    If it’s not installed, you can install it using the package manager:
    • Linux (Debian/Ubuntu):
      sudo apt-get install curl
      
    • macOS:
      brew install curl
      
    • Windows: Download from curl official website 🔗 or use a package manager like choco:
      choco install curl
      

Command

To download a file using curl, you can use the following command:

curl -o ./outputDir/filename.ext url-to-resource

Understanding commands

Let’s break down the keywords of the command:

  • curl: Invokes the curl tool.

  • -o ./outputDir/filename.ext: The -o flag specifies the output file path and name of the file. Replace ./outputDir/filename.ext with the desired directory and filename where you want to save the downloaded file.

  • url-to-resource: URL of the file you want to download. Replace url-to-resource with the actual URL of the file.