Curl for downloading file






















Today, you will find curl pre-installed in most of the Linux distros. Curl is quite a popular package and is available for any Linux distro.

However, there is no guarantee that curl is currently installed in your distro. Curl is open-source software. You can grab the curl source code and compile it manually. The following process was demonstrated in Ubuntu. For an in-depth guide on compiling curl, check out the official curl documentation. Download the curl source code here.

I have grabbed the latest version of the curl source code. At the time of writing this article, the latest version is curl v7. To demonstrate the usage of the curl program, first, we need a dummy file to download. The first line of the output tells you that it was moved, and the Location line tells you where:.

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. Time Spent : According to the hours, minutes, and seconds system, it is known as the time spent since the beginning of the transmission. Time Left According to the hours, minutes, and seconds system, it is known as the estimated time left to complete the transfer. Current Speed According to the number of bytes per second, it shows the normal transmission speed in five seconds.

Don't have a Linux machine? If you'd like the file to have a different file name perhaps readme is too bossy for you , specify it after -O : curl -o dontreadme. Use cURL to download multiple files That's all well and good, but downloading lots of files in this way would quickly become a hassle. Get cURL to follow redirects As it's common for site admins to move the location of a file, then redirect to the new one, it can be good practice to include the -L option in your cURL command.

For example, if we try to access BitLaunch's robots. We can review this redirect chain with: curl -v www.



0コメント

  • 1000 / 1000