tail icon indicating copy to clipboard operation
tail copied to clipboard

N option: Start from Nth last line

Open vanodevium opened this issue 3 years ago • 4 comments

Added new flag -N and config option N for start tailing from the last Nth line

Works only if not set Location, so it is mutually exclusive to the Location (and -n flag)

vanodevium avatar May 02 '22 19:05 vanodevium

Reading a file backwards one byte at a time is likely to be pretty bad from a performance perspective - it would make more sense to read backwards say min(512, remaining_file_size) bytes at a time and then walk backwards through that buffer one byte at a time.

ravenblackx avatar Jun 06 '22 15:06 ravenblackx

@ravenblackx I clearly understand that reading byte by byte is not the best way.

But, on the other hand, if the user specifically specifies this parameter, he clearly understands that, firstly, this operation will be one-time, and on the other hand, this is a banal consensus between functionality and speed.

So this functionality means clear aim: as user I wanna read last N lines.

vanodevium avatar Jun 06 '22 17:06 vanodevium

I changed it a bit to make better use of the current offset and whence

vanodevium avatar Jun 06 '22 18:06 vanodevium

Is there any progress on this? I like to have this function. In my case I have a file that might have X lines but really I'm only interested in "new" files. The normal unix tail -f does print the last couple of lines (fine by me). Getting the entire file is not what I'm looking for.

edit: I don't mind the performance hit, it is only done once (when first starting the 'tail')

Mattie112 avatar Jan 07 '23 18:01 Mattie112