[英]Remove HTTP Headers from CURL
I have the same problem described in 我有在描述相同的问题
Bash: Remove headers from HTTP response Bash:从HTTP响应中删除标头
The problem is that my output consists of more than one single blank line so the accepted answer will not work... 问题是我的输出包含多个空白行,因此接受的答案将不起作用...
Any suggestions? 有什么建议么?
HTTP/1.1 100 Continue
HTTP/1.1 100 Continue
HTTP/1.1 201 Ok
Date: Fri, 10 Nov 2017 08:47:06 GMT
Server: Apache
content-length: 100
content-type: application/json; charset=utf-8
cache-control: max-age=0, private, must-revalidate
Connection: close
{"user":"1234......
You can exclude the headers and print only the json response using sed
or awk
, looking for the first occurence of {
at the beginning of a line. 您可以使用
sed
或awk
排除标题并仅打印json响应,以查找{
的第一次出现在行的开头。
sed -n '/^{/,$p' file
awk '/^{/{p=1} p' file
It seems that you have already executed curl
with -i
or whatever so that you get these headers. 看来您已经用
-i
或其他命令执行curl
,以便获得这些标头。 In case you don't really need them, get only the response with a simple curl
without parameter for including headers, default printing of curl
is enough to exclude headers. 如果您真的不需要它们,则仅获取带有简单
curl
的响应,而没有包含标题的参数,默认的curl
打印足以排除标题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.