Posts Use curl to download a file
Post
Cancel

Use curl to download a file

Watch Explanation on YouTube

How to use curl to follow redirect, download a file, retry and accept self signed certificate

Link URL : https://youtu.be/9SWeUeo-Nlo

1
$ curl -L -O -k https://downloads.gradle.org/distributions/gradle-4.2.1-bin.zip .

or

1
$ curl -LOk https://downloads.gradle.org/distributions/gradle-4.2.1-bin.zip .

to download with retries

1
$ curl -LOk --retry 5 https://downloads.gradle.org/distributions/gradle-4.2.1-bin.zip .

or to download to a specific location

1
$ curl -Lk --retry 5 https://downloads.gradle.org/distributions/gradle-4.2.1-bin.zip /tmp/gradle-4.2.1-bin.zip

In above command:

1
2
3
4
5
6
7
8
9
10
11

-L is used to follow redirects

-O is used to save the downloaded file using remote name (gradle-4.2.1-bin.zip) in above example

-k is to ignore any SSL errors 

--insecure can also be used inplace of -k

--retry is to try again incase of connection drop

-k or –insecure

  • These should only be used when you are sure
  • You very well know and understand what you are upto
  • You trust the remote
  • You understand all the risks of downloading the file
  • You take full responsibility
  • And still for some odd reason you are happy to ignore the SSL errors and continue with file download
This post is licensed under CC BY 4.0 by the author.