cURL Command Cheatsheet
Fetch content from a URL
curl <url>
Example
curl https://onecompiler.com/
More Options
Option | Description | Example |
---|---|---|
-O | To download a file | curl -O https://static.onecompiler.com/images/logo/logo_transparent.png |
-OC | To download a file with resume capability | curl -OC https://static.onecompiler.com/images/logo/logo_transparent.png |
-L | Follow url redirects | curl -L https://onecompiler.com/ |
--max-redirs | Maximum redirects | curl -L --max-redirs 5 https://onecompiler.com/ |
-v | Verbose mode to see request, response headers & Connection information | curl -v https://onecompiler.com/ |
-H | To ser request headers | curl -H 'User-Agent: Robot' https://onecompiler.com/ |
-X | To specify request method | curl -X POST https://httpbin.org/post |
Frequently used Headers
Following are some of the commonly used headers with examples
- User-Agent
example:
curl -H 'User-Agent: Robot' https://onecompiler.com/
- Host
example:
curl -H 'Host: onecompiler.com' https://onecompiler.com/