简体   繁体   中英

Remove HTTP Headers from CURL

I have the same problem described in

Bash: Remove headers from HTTP response

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 -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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM