![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
uncompress/zlib with gzip data cheat sheetFrom https://newbedev.com/how-to-uncompress-zlib-data-in-unix:==CUT=== How to uncompress zlib data in UNIX?Solution: It is also possible to decompress it using standard shell-script + gzip, if you don't have, or want to use openssl or other tools. The trick is to prepend the gzip magic number and compress method to the actual data from zlib.compress: printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" |cat - /tmp/data |gzip -dc >/tmp/out Edits:
This Q on SO gives more information about this approach. An answer there suggests that there is also an 8 byte footer. Users @Vitali-Kushner and @mark-bessey reported success even with truncated files, so a gzip footer does not seem strictly required. zlipd() (printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" |cat - $@ |gzip -dc) zlib-flate -uncompress < IN_FILE > OUT_FILE I tried this and it worked for me. zlib-flate can be found in package qpdf (in Debian Squeeze and Fedora 23, according to comments in other answers) (Thanks to user @tino who provided this as a comment below the OpenSSL answer. Made into propper answer for easy access.) I have found a solution (one of the possible ones), it's using openssl: $ openssl zlib -d < /tmp/data or $ openssl zlib -d -in /tmp/data *NOTE: zlib functionality is apparently available in recent openssl versions >=1.0.0 (OpenSSL has to be configured/built with zlib or zlib-dynamic option, the latter is default) ==CUT=== |