| 场景 | 从接口响应提取关键字段 |
|---|---|
| 组合 | curl -sS + jq |
基础提取
基础提取
curl -sS https://api.example.com/status | jq -r '.data.host, .data.uptime'
curl -sS -o /tmp/r.json -w '%{http_code}\n' https://api.example.com/health
jq -r '.items[] | [.id, .name, .status] | @tsv' /tmp/r.json | column -tcurl -f 让 HTTP >=400 返回非零退出码,脚本判成功失败更可靠;-sS 保留错误信息但不显示进度。