Linux / Unix curl Command Download File Example

Linux / Unix curl Command Download File Example

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

curl -O http://example.com/file.zip
Source:ww‮ttual.w‬uri.com

This will download the file from the specified URL and save it to the current directory as file.zip.

You can also specify a different name for the downloaded file by using the -o option:

curl -o new_name.zip http://example.com/file.zip

This will download the file and save it as new_name.zip in the current directory.

If you want to download the file to a specific directory, you can use the -O option followed by the full path to the file:

curl -O /path/to/directory/file.zip http://example.com/file.zip

This will download the file and save it as file.zip in the specified directory.

You can also use the -L option to follow redirects, if the file is being served from a different URL:

curl -L -O http://example.com/file.zip

This will download the file from the URL specified in the Location header of the HTTP response, if there is a redirect.

Note: The -O option tells curl to save the downloaded file to the current directory or the specified path, and the -o option allows you to specify a different name for the downloaded file. The -L option follows redirects.

Created Time:2017-10-29 22:08:58  Author:lautturi