cURL download file and follow redirection

Downloads today seems to be more problematic than they should be, more often than not one is required to follow all them redirection to download a file.

Unfortunately it seems like it’s always faster to google for the command line options than reading the help for cURL.

curl -L -O "https://example.com/download-file.txt"

For scripting; prefer the –long-option:

curl --location --remote-name "https://example.com/download-file.txt"

If you want to specify the output filename:

curl -L -o "file.txt" "https://example.com/download-file.txt"

–long-option:

curl --location --output "file.txt" "https://example.com/download-file.txt"

Alternatives to cURL:

  • wget

Make sure to always keep your Operating System(s) and all of the software that you are using up to date.

Feedback on our content or did you find a bug somewhere?

Send us an email to feedback at this domain.

kthxbai