首页 > 解决方案 > 想要存储对 cURL 请求的响应,但请求本身也被存储。如何让它静音?

问题描述

我正在尝试在 bash 中运行以下行:

var=$(curl -Sid $'my_message\r\n' "http://localhost:9000" > my_file)

wherelocalhost:9000只是一个简单的回显服务器。

但是,当我查看 my_file 时,会打印以下内容:

HTTP/1.1 200 OK
Content-Length: 159
Content-Type: text/plain

POST / HTTP/1.1
Host: localhost:9000
User-Agent: curl/7.58.0
Accept: */*
Content-Length: 12
Content-Type: application/x-www-form-urlencoded

my_message

如何确保仅打印以下(响应)?

HTTP/1.1 200 OK
Content-Length: 12
Content-Type: text/plain

my_message

我尝试使用-sand-S标志,但它们似乎没有奏效。

标签: bashcurl

解决方案


推荐阅读