| 用途 | HTTP(S) 请求 / 下载 / 调试 |
|---|---|
| 语法 | curl [选项] URL |
| 常用 | -s 静默 -S 显示错误 -L 跟随重定向 -o 输出文件 |
常用示例
常用示例
curl -sS https://example.com # 静默但保留错误
curl -sS -o page.html https://example.com # 保存响应
curl -sSL https://example.com # 跟随 301/302
curl -sS --max-time 10 --retry 2 https://api.example.com/health
curl -sS -w 'code=%{http_code} time=%{time_total}s\n' -o /dev/null https://example.com运维脚本里 -sS 标配:静默进度但错误仍输出;只看状态码用 -o /dev/null -w 组合。