How to download a file using curl command

October 17, 2023 / Command Line

This article explains how to download a file using curl command. The curl command is a versatile command-line tool used to transfer data to or from a server.

Follow the steps-

  1. Retrieve the file using curl run-
    $ curl https://your-domain/file.pdf
  2. Get file using ftp or sftp protocol-
    $ curl ftp://ftp-your-domain-name/file.tar.gz
  3. While using curl to download a file, you can specify the desired output file name by running-
    $ curl -o file.pdf https://your-domain-name/long-file-name.pdf
  4. To follow a 301-redirected file during a file download using curl, use the following command-
    $ curl -L -o file.tgz http://www.cyberciti.biz/long.file.name.tgz

This way, you can download a file using curl command.

An easy way to download files from the command line is to use the curl command. Sometimes you may need to provide a more user-friendly experience for file downloads on your website. In that case, you can allow your users to download files just by clicking on the link.

For this, you can explore our guide on How to download files upon a click on a link. This method allows you to create direct download links on your web pages making the process easier for your visitors.

 

Spread the love