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
  • 1
  • 12

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
  • 1
  • 1
  • 12
coteyr
  • 17,948
  • 6
  • 29
  • 57
  • 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
  • 1
    bzip2.c line 1298 only file to file mode even checks keepInputFiles set by the argument parser. – coteyr May 17 '13 at 16:05