Wget Curl



For curl, it returns no output at all, but with wget, it returns the entire HTML source: Here are the 2 commands. I've used the same user agent, and both are coming from the same IP, and are following redirects. The URL is exactly the same. Do this in your GUI browser, like chrome or firefox. First create an account in oracle and Signin. Click here to download oracle for Linux and accept the license. Click the files you want to download and while downloading just pause it copy the download link. Now go to your terminal, install wget or curl. Apt-get install wget curl.

Question: I typically use wget to download files. On some systems, wget is not installed and only curl is available. Can you explain me with a simple example on how I can download a remote file using curl? Are there any difference between curl and wget?

Answer: On a high-level, both wget and curl are command line utilities that do the same thing.

  • They both can be used to download files using FTP and HTTP(s).
  • You can also send HTTP POST request using curl and wget
  • However curl provides APIs that can be used by programmers inside their own code. curl uses libcurl which is a cross-platform library.
  • wget is just a command-line tool without any APIs.
  • Curl also supports lot more protocols that wget doesn’t support. For example: SCP, SFTP, TFTP, TELNET, LDAP(S), FILE, POP3, IMAP, SMTP, RTMP and RTSP.
  • There is a major advantage of using wget. wget supports recursive download, while curl doesn’t.

Wget Examples

Wget Curl

The following example downloads the file and stores in the same name as the remote server.

The following example download the file and stores in a different name than the remote server. This is helpful when the remote URL doesn’t contain the file name in the url as shown in the example below.

More wget examples: The Ultimate Wget Download Guide With 15 Awesome Examples

Curl Examples

Option -O (upper-case O) is important. Without this, curl will start dumping the downloaded file on the stdout. Using -O, it downloads the files in the same name as the remote server. In the above example, we are downloading strx25-0.9.2.1.tar.bz2, so the downloaded file will also be the same name.

Instead of -O, you an also specify, “–remote-name” as shown below. Both are the same.

While curl is downloading it gives the following useful information:

  • % – The total % of the download that was completed as of now. When it gets to 100% the download is completed. In the above example, it has downloaded only 28% of the file.
  • Total – The total size of the file
  • Received – The total size of the file that was has been downloaded so far. In the above example, it has downloaded 1085k so far (out of 3762k total)
  • Xferd – This will be used when you upload some files to the remote server. During upload, this will indicate the total size of the file that has been uploaded so far. Since we are downloading a file, in this example, this is 0.
  • Average Speed Dload – This indicates the average download speed.
  • AVerage Speed Upload – While uploading a file, this will indicate the average upload speed
  • Time Total – This indicates the total time it will take to download (or upload) the whole file based on the current download (or upload) speed. In this example, it will take approximately a total of 52 seconds to download this file.
  • Time Spend – The time curl has spent so far downloading (or uploading) the file. In this example, it has spent 15 seconds so far.
  • Time Left – This is caculated based on “Time Total” – “Time Spent”.
  • Current Speed – This indicates the current download/upload speed. Compare this with Average Spped Dload/UPload to see how fast or slow your system is downloading currently.

If you want to download the file and store it in a different name than the name of the file in the remote server, use -o (lower-case o) as shown below. This is helpful when the remote URL doesn’t contain the file name in the url as shown in the example below.

What Curlers Are The Best

In the above example, there is no file name in the remote URL, it just calls a php script that passes some parameter to it. However, the file will be downloaded and saved as taglist.zip on your local system. Instead of -o, you an also specify, “–output”.

More curl examples: 15 Practical Linux cURL Command Examples

When it comes to downloading files from the internet, we usually imagine pressing the download button. However, you can also download files directly from your terminal. Wget and Curl are two of the popular tools that let you do that.

In this tutorial we will look at these two and see how the two differ.

The curl command transfers data from any server over to your computer. Whereas the wget command downloads the data as a file. This is the major difference between the two commands.

Installation of wget and curl commands

If you don’t have wget or curl on your system you can download by following the steps given below.

Steps to install curl on different distros

To install Curl on your system use the following command :

Steps to install wget on different distros

To install Wget on your system use the command :

Difference between curl and wget

Let’s see how the outputs of two commands differ when we use them.

Wget Curl Windows

Accessing a website with curl

To see what the output of curl command looks like, try running curl on a few websites.

We can see that curl displays data from the website on the terminal itself. We can also save the output to a file.

To save the output to a file use the following command :

The output is different from the one above. To view the file where the output is saved use cat command.

Alternatively you can also use the following command to store the output in a file.

Accessing a website with wget

To see what the output of wget command looks like, try running wget on a few websites.

We can see that Wget stores the output in a file by default. It also shows a progress bar in the output.

Wget command will simply download a file based on the file name that’s provided by the server. Alternatively, you can set a filename by using the -0 flag.

You can use the cat command to display the file.

Similarities between wget and curl

What Curling

  • Both Wget and Curl can download files off the internet.
  • Both Curl and Wget support HTTP and its secure version, HTTPS.
  • Both are command-line tools.
  • Both support HTTP cookies.
  • Both are capable of making HTTP post requests.
  • Both are completely open-source and free software.

You might be wondering then what’s the difference between the two. Let’s look at the difference next.

Differences between wget and curl

Wget Curl Difference

Conclusion

What Curly Brackets Denote In Mathematics

This tutorial was about the difference between wget and curl. If you want a tool to just download files over the internet, you should use Wget. If you want some features apart from just downloading then you should go for curl.