Skip to content

Instantly share code, notes, and snippets.

@jevinskie
Created April 13, 2021 18:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jevinskie/93fa312c61ab2bef0a0afa9f8cd268e8 to your computer and use it in GitHub Desktop.
Save jevinskie/93fa312c61ab2bef0a0afa9f8cd268e8 to your computer and use it in GitHub Desktop.
raw zlib/deflate compress/decompress shell functions
function unzlib {
exec 9<&0
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - ${1:-/dev/fd/9} | gzip -dc
}
function zlib {
cat ${1:-/dev/stdin} | gzip -c | tail -c +9
}
function undeflate {
exec 9<&0
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00" | cat - ${1:-/dev/fd/9} | gzip -dc
}
function deflate {
cat ${1:-/dev/stdin} | gzip -c | tail -c +11
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment