J O S E P H J O S E P H

cURL

Basic usage

Get only the response status code from a request.

curl -s -o /dev/null -w "%{http_code}\n" http://example.com  #=> 200

# Description
-s                   # Silent mode. Don't show download progress.
-o /dev/null         # Suppress the response body
-w "%{http_code}\n"  # Write-out the numerical response code (+ newline)

Pretty-print JSON response body using jq (must have jq installed already).

curl -s https://official-joke-api.appspot.com/random_joke | jq .

Download to file

Write output to a local file instead of stdout.

curl http://example.com/some-file.txt -o ./myfile.txt

Write output to a local file named like the remote file.

curl -O http://example.com/some-file.txt