用 curl -C - 断点续传下载
curl 会根据已有输出文件的大小,从中断处继续下载。
用 `curl -C - -O <URL>` 重新运行同一命令;`-C -` 中的连字符让 curl 从已有文件推断续传偏移。
01命令
命令
$ curl -C - -L -O https://example.com/big-file.iso
# Resume with a manual output name:
curl -C - -L -o big-file.iso https://example.com/big-file.iso02作用说明
`-C -` 让 curl 检查磁盘上已有的输出文件,并从该字节起发送 Range 请求——支持范围请求的服务器会无缝续传,若文件已完整,curl 会返回 `HTTP 416`。配合 `-L` 跟随重定向、`-O` 复用远程文件名,或用 `-o 名称` 自定义输出。下载 5GB 文件在 80% 处断线时,这就是标准解法。
03风险
!注意: 若服务器忽略 Range 头,`-C -` 会重新下载或报错而非续传——请看 curl 进度输出的第一行。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- curl — macOS Command Reference依据: Documents the -C - (auto-resume) and -O/-o output flags.
- Downloads — everything curl依据: Explains how -C - infers the resume offset from the existing output file.
最后验证: 2026-09-17 · 分类: 网络