输出变量需要按照%{variable_name}的格式,如果需要输出%,使用%%即可。
-w 指定格式化文件
-o 请求重定向到,不带此参数则控制台输出返回结果
-s 静默,不显示进度
curl -o /dev/null -s -w %{http_code}:%{http_connect}:%{content_type}:%{time_namelookup}:%{time_redirect}:%{time_pretransfer}:%{time_connect}:%{time_starttransfer}:%{time_total}:%{speed_download} www.baidu.com
#cat ~/curl_time.txt
http: %{http_code}\n
dns: %{time_namelookup}s\n
redirect: %{time_redirect}s\n
time_connect: %{time_connect}s\n
time_appconnect: %{time_appconnect}s\n
time_pretransfer: %{time_pretransfer}s\n
time_starttransfer: %{time_starttransfer}s\n
size_download: %{size_download}bytes\n
speed_download: %{speed_download}B/s\n
----------\n
time_total: %{time_total}s\n
#curl -w "@~/curl_time.txt" -s -H "Content-Type: application/json" www.baidu.com