I couldn't find a command-line tool for decompressing and compressing zlib data, so I wrote my own. That's about the long and short of it.
Update: @stokito noted that pigz
exists and can do zlib compression with pigz -z
. Nice!
Download a release or install the latest directly using Go:
go install github.com/kevin-cantwell/zlib/cmd/zlib@latest
For older versions of Go, try:
go get -u github.com/kevin-cantwell/zlib/cmd/zlib
Without any arguments, zlib will compress an input stream. Use the -d
flag for decompression.
NAME:
zlib - A wrapper for the zlib compression algorithm.
USAGE:
zlib [global options] command [command options] [arguments...]
VERSION:
0.0.0
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
-d, --decompress Decompresses the input instead of compressing the output.
--help, -h show help
--version, -v print the version
zlib < file > file.zlib
zlib -d < file.zlib
echo -n '{"foo":"bar"}' | zlib | base64
Outputs: eJyqVkrLz1eyUkpKLFKqBQQAAP//HXoENA==
echo -n 'eJyqVkrLz1eyUkpKLFKqBQQAAP//HXoENA==' | base64 -D | zlib -d
Outputs: {"foo":"bar"}