0

I have multiple huge gzipped text files. I have to read the first and last n lines without loading the whole file into memory using head and tail like functions. For plain text files I use a tail like function similar to this answer.

However I want to avoid unzipping the files first. I have implemented a head like function working on gzipped files using a technique similar to this answer. But I fail to implement a tail like function that works with gzipped files.

Jan Hajer
  • 232
  • 2
  • 14

1 Answers1

0

Can't be done without running through the entire file and decompressing, at least in memory.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158