Linux Commands

Examples of the Curl Get Command

In Linux, the client for URLs or Curl is a popular command-line utility that allows you to transfer the data over a network using numerous protocols such as HTTPS, HTTP, FTP, etc. It lets you send and receive the data using its get, post, and request methods. Among these, you need to use the “get” method very often. Hence, it becomes essential for you to learn the ways and various options that you can use to boost your productivity.

“Curl get” is easy and it requires you to enter the simple commands. Despite this simplicity, many users are unaware of its true potential. Therefore, this short guide has some examples of the “curl get” command in Linux.

Some Examples of the Curl Get Command

In this section, we will see a few examples of the “curl get” command including various scenarios that you will face while using the command.

Example 1: Simple “Curl Get”
To send a “get” request to a URL, the “curl” command would be:

curl https://abcd.com/123

Upon execution, it prints the received response in the command line.

Example 2: Follow the Site Redirects
Some website URLs redirect you to another URL. So, the server responds with a redirect status code of “30x”. Thus, in like situations, you can use the following command:

curl -L https://abcd.com/123

The “-L” option instructs “curl” to follow the redirects (if found any).

Example 3: Save the Output to a Text File
Say you want to save the response from the “get” request to a text file named “output.txt”. Use the following command:

Curl -o output.txt https://abcd.com/123

Example4: Verbose Output
The verbose output produces a detailed display of the response which is commonly used for debugging purposes. For this, use the “-v” option:

curl -v https://abcd.com/123

Example 5: Limit the Transfer Speed
When you download something using the “curl get” method, it occurs at the highest possible download speed. You can control it by imposing a speed limit:

curl --limit-rate 1024K  https://abcd.com/123/downloads

Conclusion

The “curl get” command is a method that you can use to retrieve the data from the internet. Learning it is essential for users, especially for beginners. However, its various use cases can cloud your understanding, so we came up with this guide. Here, we took examples of various situations and demonstrated their solutions.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.