# Curl ## Fetch headers curl --head "https://example.com" ## List contents of a directory curl --list-only "https://example.com/foo/" ## Redirect query as specified by a 3xx response curl --location "https://iana.org" ## Fail quickly curl --fail-early "http://opensource.ga" ## Download a file, saving the file without changing its name curl --remote-name "https://example.com/linux-distro.iso" ## Download a file, renaming the file curl --remote-name "http://example.com/index.html" --output foo.html ## Continue a partial download curl --remote-name --continue-at - "https://example.com/linux-distro.iso" ## Download a file from multiple domains curl "https://www.{example,w3,iana}.org/index.html" --output "file_#1.html" ## Download a sequence of files curl "https://{foo,bar}.com/file_[1-4].webp" --output "#1_#2.webp" ## Download all PNG files from a site (uses GNU grep) curl https://example.com | grep --only-matching 'src="[^"]*.[png]"' | cut -d\" -f2 | while read i; do curl https://example.com/"${i}" -o "${i##*/}"; done ## Check whether a website is down curl --head --show-error "http://example.com" ## Expand a shortened URL curl --head --location "https://bit.ly/2yDyS4T" ## Query an API endpoint curl "https://gitlab.com/api/v4/projects" ## Send raw data curl --data "Some data" "https://example.com/api/v4/endpoint" ## Send form data (emulates a form and Submit button) curl --form "username=seth" --form "password=12345678" "https://example.com/api/v4/endpoint" ## Send a file as form data curl --form "avatar=@me.jpg" "https://example.com/foo/bar" ## Send contents of a file as form data curl --form "description=