Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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