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.)


1 Answer 1


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

  • 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, 2013 at 15:51
  • 1
    bzip2.c line 1298 only file to file mode even checks keepInputFiles set by the argument parser.
    – coteyr
    May 17, 2013 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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