How to pipe differently the body of the curl answer and the printed output?
- by Antoine Lizée
I would like to print in the command line some output of curl, like the http headers, followed by the body of the answer processed by a stdin/stdout program. For instance:
Print the status code:
curl -s -w "%{http_code} \\n" -o "/dev/null" http://myURL.com
And then process the output with a json parsing tool:
curl -s http://myURL.com | python -mjson.tool
I would like to do both with one command, and I have the feeling that it may be possible thanks to the -o option that makes the difference between the output of curl and the actual answer from the query. The problem is that -o writes directly to a file. Somebody's got a hack?