Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

By default, bzcat (or, equivalently, bzip2 -dc or bunzip2 -c) will keep the source (compressed file) and not delete it. Is there a flag or other means (besides thereafter manually rming the file) to delete the compressed file when using bzcat or one of its equivalent commands?

(The reason I want to do this — in case you're wondering — is that I wish to sed-modify the output for immediate use after teeing the unmodified output to a file. I can of course instead bzcat | sed ; bunzip2, but that requires two decompressions. Any other solution for my actual problem is certainly welcome in lieu of an answer to the question I pose above.)

share|improve this question
up vote 1 down vote accepted

Why not

bzcat file | tee no_modifications | sed blah blah


This would decompress, tee (or split the data) into a file call no_modifications and stdout which you pipe into sed for "immediate use".

If you really want to delete the original then I'm afraid you're down to

bzcat file | tee no_modifications | sed blah blah && rm file

share|improve this answer
So your answer is "No, there's no such means". Okay, thanks! Any support you can provide for that claim would boost its reliability. – msh210 May 17 '13 at 15:51
bzip2.c line 1298 only file to file mode even checks keepInputFiles set by the argument parser. – coteyr May 17 '13 at 16:05
I see that on line 6263, but, yeah, thanks. – msh210 May 17 '13 at 16:29

Your Answer


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.