Compress command output by piping to bzip2
Solution 1:
You can do this with bzip2
's -c
option:
-c --stdout
Compress or decompress to standard output.
For example:
command | bzip2 -c > some.txt.bz2
And to decompress:
bzip2 -dc < some.txt.bz2 | less
Solution 2:
The bzip2 utility will compress stdin but won't write it to stdout if stdout is a terminal. You can though use standard output redirection techniques.
command | bzip2 >somefile.txt.bz2
and to read it the usual tools are available e.g.
bzless somefile.txt.bz2