How can I tail a zipped file without reading its entire contents?

前端 未结 7 1410
温柔的废话
温柔的废话 2020-12-15 15:35

I want to emulate the functionality of gzcat | tail -n.

This would be helpful for times when there are huge files (of a few GB\'s or so). Can I tail the last few li

7条回答
  •  半阙折子戏
    2020-12-15 16:04

    No, you can't. The zipping algorithm works on streams and adapts its internal codings to what the stream contains to achieve its high compression ratio.

    Without knowing what the contents of the stream are before a certain point, it's impossible to know how to go about de-compressing from that point on.

    Any algorithm which allows you to de-compress arbitrary parts of it will require multiple passes over the data to compress it.

提交回复
热议问题