bash - 想要存储对 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
我尝试使用-s
and-S
标志,但它们似乎没有奏效。
解决方案
推荐阅读
- django - Django Signal没有将用户添加到组
- ios - iOS 应用程序通过分页使用多个 JSON
- c++ - 错误:无法将“int&”类型的非常量左值引用绑定到“int”类型的右值
- json - 我无法访问 json 响应 Swift 4 中的值
- node.js - 如何将数据从客户端的 html 发送到 node.js 服务器?
- r - 在一个选项卡上编辑数据框,并在 R Shiny Dashboard 中的另一个选项卡上正确加载
- android - 您如何解析带有定义数组的 JSON 数组?
- mysql - 使用 MongoDB 和 Spring Data MongoDB 进行日期查询
- node.js - npm global install 给出 EISDIR 警告和 ENOENT 错误
- javascript - 未定义 Javascript 数组名称