If you don't know what format the binary output has it would be safer to inspect the output format first.
Otherwise as you already use
-s, for silent mode like in batch/automation scripts, you could directly pipe it on to a suitable binary-converter.
Or, assuming the HTTP output was compressed, simply decompress it.
Inspecting binary curl output
-I to see response-headers only and view
Content- headers for a given media type (also known as MIME type) indicating the (binary) format:
curl -k -L -s https://www.mi.com -I
curl -k -L -s https://www.mi.com -I | grep Content- will also show other output-metadata like encoding (e.g. UTF-8), length in bytes (here 169747 bytes, after redirection):
Content-Type: text/html; charset=utf-8
Note: above HTTP request was redirected, thus we get 2 responses and 2 response-headers from curl. The first is from redirection, the second from final output.
- Pipe to
type to inspect the binary data type (file-type):
curl -k -L -s https://www.mi.com | type
--output to save to a file:
curl -k -L -s https://www.mi.com -o outFile
Same like redirection
> outFile suggested by terdon.
Passing binary output on (e.g. to an image-viewer)
You can also use the pipe to pass e.g. an image indicated by response-header
Content-Type: image/x-icon to a stdin-accepting viewer like
feh to show it:
curl -k -L -s https://www.mi.com/favicon.ico | feh
De-compressing curl output
Binary output may be the result of HTTP compression which is often used to save bandwidth and speed-up transmission.
- Piping to
zcat to view unzipped directly:
curl -k -L -s https://www.mi.com | zcat
If curl's output was not zipped as expected following warning will show:
gzip: stdin: not in gzip format
As terdon explained interactively.
curl -k -L -s https://www.mi.com --compressed
As Stephen already answered.