Useful curl switches

In a similar vein to my previous post I want to have a place where I keep track of all the useful curl switches.

    • -L follow redirects
    • -s silent
    • -v verbose
    • -o output file
    • -H (or --header) send custom headers
    • -d (or --data) send data (inline, or a file specified by @<filename>)
    • --data-binary same as above for binary files
    • -X "METHOD" to make a request of custom method
  • -k skip any SSL checks (useful for self-signed certs)

Request types:

    • By default curl does a GET request.
    • -d or -F makes it a POST request.
    • -I generates a HEAD (use this to view headers only)
    • -T sends a PUT
    • -X "METHOD" for a custom method (which could be GET or POST etc.)

    View Response Headers:

    • -s : Avoid showing progress bar
    • -D - : Dump headers to a file, but - sends it to stdout
    • -o /dev/null : Ignore response body

    This is better than -I as it doesn’t send a HEAD request, which can produce different results.

It’s better than -v because you don’t need so many hacks to un-verbose it. Thanks SO.

Finding where a Url redirects to:

  • -L follow redirects
  • -s silent
  • -o output file (to /dev/null in this case as we don’t care for the output)
  • -w what to output after completion (in this case url_effective followed by two new lines as I like to space things out)

Thanks again, SO.