首页 / Linux 命令行入门教程 / 63. curl 与 wget 下载

Linux 命令行入门教程

63. curl 与 wget 下载

本教程共 90 篇 · 第 63 篇

63. curl 与 wget 下载

从网上下文件、调接口,curl 和 wget 是两条主力。

curl 默认把内容打印到屏幕,不存盘。要下载得加 -O(用原名)或 -o(指定名):

curl -O https://example.com/file.zip
curl -o my.zip https://example.com/file.zip

遇到跳转(301/302)要跟过去,加 -L

curl -L -O https://example.com/file.zip

测接口常用。发 GET:

curl https://api.example.com/status

发 POST 带数据:

curl -X POST -d "key=value" https://api.example.com/submit

wget 更简单,默认就下载存盘:

wget https://example.com/file.zip

断点续传用 -c,大文件中断了接着下:

wget -c https://example.com/big.iso

后台下载 -b,进度写进 wget-log。

Tip

小文件、调 API 用 curl;单纯下载、要续传用 wget。两者 Ubuntu 26.04 都可用(curl 默认可用,wget 一般也已装)。

小结:curl 灵活、擅长发请求;wget 专注下载、支持续传。按需挑。

参考来源