1

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

msh210
  • 115

1 Answers1

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

msh210
  • 115
coteyr
  • 18,724