mynetx

curl: Resume broken downloads

With the Unix curl command, you can perform basically every web request that might come to your mind. It can even download files to your disk. But what can you do if you started a download in the size of a 3-storey wedding cake, and it cancelled at 87%? curl has got you covered.

In order to resume broken downloads, use the curl command with the -C parameter. “C” is short for “Continue at XY bytes”. By default – that is, if you don’t indicate any manual byte offset behind –, curl will try to figure out where the download left off, and resume from there. It will also tell you the exact offset that it starts from.

Here’s a full example:

curl -L -o 'cake.iso' -C - http://www.example.com/delicious-wedding-cake.iso

This code will work in any shell that supports the curl command – except that the file URL doesn’t really exist. (I would be stupid to tell you where to get a delicious wedding cake for free, wouldn’t I?) But I guess you can drop in your personal cake URL with ease.