Curl command to download a file
You could use curl to make another request manually, or you can use the --location or -L argument which tells curl to redo the request to the new location whenever it encounters a redirect. Give it a try:. You can combine the -L argument with some of the aforementioned arguments to download the file to your local system:. Warning : Many resources online will ask you to use curl to download scripts and execute them.
You can learn more by viewing the manual page for curl by running man curl. Where would you like to share this to? Twitter Reddit Hacker News Facebook.
Share link Tutorial share link. Sign Up. DigitalOcean home. Community Control Panel. Do not! If you do not know the exact value of the offset, do not worry, you just need to specify -C - to tell cURL to automatically find out that value. If the requested file requires basic authentication, you need to use the -u option followed by the credential which is in the form of user:password :.
To read more about basic authentication, you can read the article 3 methods to use basic authentication with cURL. To see more examples, you can read the article How to use a proxy with cURL. This is partly because of its lack of interactivity - when you download a file with cURL it doesn't ask for confirmation and can transfer multiple files at once. This makes it ideal for automation if you trust the source. Today we'll be walking you through the basics of using curl to download a file. Our sample file will be the readme for blcli, BitLaunch's command-line interface , which is hosted on GitHub.
In the case of our readme, the complete command would like this:. So what if we want to use cURL to save a file to our server? For that, we must use the -O option:. You'll notice that cURL will display a download progress table rather than the file contents this time:.
0コメント