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.