curl Command Resume Broken Download

by on March 9, 2014 · 1 comment· LAST UPDATED March 9, 2014

in , , ,

I know wget can resume a failed download. I am on a Mac OS X and do now want to install wget command. How can I resume a failed download using curl command on Linux or Unix-like systems?

You can continue getting a partially downloaded file using curl command. You need to pass the -C or --continue-at <offset> option resume a previous file transfer at the given offset.
Tutorial details
DifficultyEasy (rss)
Root privilegesNo
Estimated completion time1m

curl resume broken download

COMMAND command
The syntax is as follows to to automatically find out where/how to resume the transfer using curl command:

curl -C - url


curl -L -O -C - url


curl -L -o 'filename-here' -C - url

In this example, finish a download started by a previous instance of curl command:

curl -L -O -C -
Animated gif 01: Resume a broken download

Animated gif 01: Resume a broken download

If there is a file named CentOS-6.5-x86_64-bin-DVD1.iso in the current directory, curl will assume that it is the first portion of the remote file, and will ask the server to continue the retrieval from an offset equal to the length of the local file. Thus, it will result in saving both time and bandwidth.

Another example

You can continue a previous file transfer at the given offset. The given offset is the exact number of bytes that will be skipped, counting from the beginning of the source file before it is transferred to the destination. The syntax is:

curl -C offset url

In this example, retrieve ifdata-welcome-0.png file using the following command:

## Get first 20000 bytes ##
curl  -o file.png --header "Range: bytes=0-20000"
## Resume at 20001 offset and download the rest of the file ##
curl -o file.png -C 20001
## View an image file using a local image viewer ##
ls -lh file.png
open file.png

Sample outputs from ls command:

-rw-r--r--@ 1 vivek  wheel    30K Feb 28 23:24 file.png
See also
Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 1 comment… read it below or add one }

1 Rahul Jawale April 24, 2015 at 2:39 pm

Awesome! Saved 4 GB worth of FUP data this way. :)


Leave a Comment

Tagged as: ,

Previous Faq:

Next Faq: