I have been getting confused by how many interpretations and conditions for 
chasing tail people seem to be talking about.
A fairly normal task is to want to see just the last N lines of a text-based 
file. 
A variant is the "tail -f" command from UNIX that continues to follow a growing 
file, often into a pipeline for further processing.
The variant now being mentioned is a sort of "reverse" that has nothing to do 
with that kind of "tail" except if the implementation is to read the file 
backwards. A very straightforward way to reverse a file takes perhaps two lines 
of Python code by reading forward to fill a list with lines of text then using 
an index that reverses it.
The issues being considered are memory and whether to read the entire file.
I would think reading a file forwards in big chunks to be far faster and 
simpler than various schemes mentioned here for reading it backwards. It only 
makes sense if the goal is not reversal of all the contents.
Also noted is that memory use can be minimized various ways so that only 
thefinal results are kept around. And if you really want more random access to 
files that you view as being organized as lines of text with a fixed or maximum 
width,then storing in some database format, perhaps indexed, may be a way to go.

A time stamped log file is a good example.
So which problem is really supposed to be solved for the original question?



-----Original Message-----
From: Roel Schroeven <r...@roelschroeven.net>
To: python-list@python.org
Sent: Sun, Apr 24, 2022 5:19 am
Subject: Re: tail

dn schreef op 24/04/2022 om 0:04:
> Disagreeing with @Chris in the sense that I use tail very frequently,
> and usually in the context of server logs - but I'm talking about the
> Linux implementation, not Python code!
If I understand Marco correctly, what he want is to read the lines from 
bottom to top, i.e. tac instead of tail, despite his subject.
I use tail very frequently too, but tac is something I almost never use.

-- 
"Peace cannot be kept by force. It can only be achieved through understanding."
        -- Albert Einstein

-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to