cURL Command Cheatsheet




Fetch content from a URL

curl <url>

Example

curl https://onecompiler.com/

More Options

OptionDescriptionExample
-OTo download a filecurl -O https://static.onecompiler.com/images/logo/logo_transparent.png
-OCTo download a file with resume capabilitycurl -OC https://static.onecompiler.com/images/logo/logo_transparent.png
-LFollow url redirectscurl -L https://onecompiler.com/
--max-redirsMaximum redirectscurl -L --max-redirs 5 https://onecompiler.com/
-vVerbose mode to see request, response headers & Connection informationcurl -v https://onecompiler.com/
-HTo ser request headerscurl -H 'User-Agent: Robot' https://onecompiler.com/
-XTo specify request methodcurl -X POST https://httpbin.org/post

Fequently used Headers

Following are some of the commonly used headers with examples

  1. User-Agent example:
curl -H 'User-Agent: Robot' https://onecompiler.com/
  1. Host example:
curl -H 'Host: onecompiler.com' https://onecompiler.com/


┬ęCopyright 2020 OneCompiler | Privacy Policy | Terms & Conditions