Download a file with resume support

Low risk
What do risk levels mean?
Read-only
Inspects state without changing anything.
Low risk
Reversible with a routine follow-up command.
Medium risk
Changes state; undo path documented.
Destructive
Deletes or overwrites; confirmation required.

Downloads a file to a chosen path, following redirects, and resumes from where it stopped if the transfer is interrupted — useful for large files on unreliable connections.

networkdownloadcurlresume

Parameters

URL of the file to download.

Local path to save the file to.

Commands

Download the file, resuming any partial transfer at the output path

curl -L -C - -o <output_file> <url>

Verification

ls -l <output_file>

The file exists with the expected size; rerunning the download prints that the transfer is already complete.

Undo

Delete the downloaded file

rm <output_file>

Pitfalls

  • Resume only works when the server supports HTTP range requests; otherwise curl restarts the download from the beginning.
  • If the remote file changed since the partial download, resuming produces a corrupt file; delete the partial file and start over.
  • Verify checksums (shasum, sha256sum) for downloaded software before executing it.
  • The verification and undo commands use macOS/Linux syntax; on Windows use "Get-Item {{output_file}}" to verify and "Remove-Item {{output_file}}" to undo.

Related