Clever Curl



My personal cURL cheat sheet

Downloading files

Resuming failed download

Need to make sure filename is the same in order for it to automatically determine the offset. The - after -C tells it to use the output file to determine where to continue from.

curl -O -C -

Output filename

-O uses the filename from the end of the path.

curl -O

This can be annoying if it has query parameters, because they will end up in the filename. If you add -J it lets curl use the filename provided by the server (via the Content-Disposition header) if one is available.

curl -OJ

Uploading files

Prefer --data-binary to --data/-d because it doesn't mess with newlines etc.

curl --data-binary @filename.bin

-T option will make a PUT request. Advantage over --data-binary is that it doesn't load the entire file into memory on the client. You can use -X POST to force it to use POST.

curl -T filename.bin

Like what I have to say? Consider subscribing to my newsletter. I don't send very many updates.