Is there some way to continually compress the output of a program (in almost realtime)?

For example I have this program that produces (a lot of) output to stderr. I want to do something like ./my-program 2> tar -<someoptions> stderroutput.tar.gz

2 Answers 2


If I understand correctly, you want to compress the contents of the standard error stream and save it to a file. If so, try this: ./my-program 2>&1 | gzip > stderroutput.gz


tar does not compress data; it is designed only to archive multiple files into one. To compress streams, you would need to use gzip, xz, bzip2 or similar. (While gzip has the worst compression rate, it is also one of the fastest, so it might be the best choice here.)

For example:

myapp 2> >(gzip > stderr.gz)


(myapp 2>&1 1>&3 | gzip > stderr.gz) 3>&1
  • I wasn't aware that tar doesn't compress data (only files). Thanks.
    – Anand
    Feb 24, 2012 at 22:50
  • @trex279: Strictly speaking, tar doesn't compress at all. It only packs files into archives, and automatically calls gzip/etc to perform compression.
    – user1686
    Feb 24, 2012 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.