How to download a file with curl on Linux/Unix command line

To download a file using the curl command on the Linux or Unix command line, you can use the following syntax:

curl [options] [URL] -o [filename]

For example, to download the file at https://www.example.com/file.txt and save it as file.txt on your local system, you would run:

curl https://www.example.com/file.txt -o file.txt

In this example, https://www.example.com/file.txt is the URL of the file to be downloaded, and -o file.txt specifies the output filename.

Here are some additional options that you may find useful when downloading a file using curl:

  • -L: Follow redirects.
  • -O: Save the file with the same name as on the remote server.
  • -C -: Resume a partially-downloaded file.
  • -#: Display a progress meter while downloading the file.
  • -k: Allow insecure SSL connections.

For more information on using curl, you can consult the curl manual page by running man curl in a terminal window.

Leave a Comment