如何使用带有多个数据令牌的curl -w开关作为格式参数?

时间:2015-12-10 07:00:09

标签: bash curl

我希望从单个http_code请求获得curl:time_totalcurl两件事。我该如何制定-w %{insert_formatting_here}

这些作品:

result = $(curl -s -w %{http_code} -o temp.txt) "http://127.0.0.1" 
echo "$result"
result = $(curl -s -w %{time_total} -o temp.txt) "http://127.0.0.1" 
echo "$result"

结果:

200
0.004

但这并不像我预期的那样有效:

result = $(curl -s -w %{http_code time_total} -o temp.txt) "http://127.0.0.1" 
echo "$result"

结果:

<p>where "$CATALINA_HOME" is the root of the Tomcat installation directory. If you're seeing this page, and you don't think you should be, then you're either a user who has arrived at new installation of Tomcat, or you're an administrator who hasn't got his/her setup quite right. Providing the latter is the case, please refer to the <a href="/docs">Tomcat Documentation</a> for more detailed setup and administration in %{http_codeReserved99-2014 Apache Software Foundation<br/>ht="80" alt="Powered by Tomcat"/><br/>s working on Tomcat</li>configuring and using Tomcat</li> developing web applications.</p>

我找不到任何帮助我在format参数上放置多个标记的教程。他们只列出格式标记,但到目前为止还没有示例或任何内容。

1 个答案:

答案 0 :(得分:1)

每个占位符都必须在括号内,即:

curl -s -w "%{http_code}:%{time_total}" http://127.0.0.1