Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 2 down vote accepted

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

share|improve this answer

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)

or

(myapp 2>&1 1>&3 | gzip > stderr.gz) 3>&1
share|improve this answer
    
I wasn't aware that tar doesn't compress data (only files). Thanks. – anand.trex Feb 24 '12 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. – grawity Feb 24 '12 at 23:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .