[fpc-pascal] read lines at end of file

Robert Wolfe wolfe.robwolfe at gmail.com
Tue Apr 12 01:09:34 CEST 2011


On 04/11/2011 12:32 PM, John Lee wrote:
> Need to read the last 4 lines (txt) of a very large log file 100M 
> bytes, 100k lines or more  lots of times - of course I can read 
> through the file in the normal way but this is rather slow. Is there a 
> way to 'read lines from the end'? I note that unix tail or its port to 
> windows does this very fast so guess there must be a fast way to do it 
> in pascal too?
>
> TIA for any ideas John
>
>
>
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Hmm, could first have the reader enumerate the number of lines in the 
file, then read through the files using the "total number of lines - 4" 
variable and then start displaying the lines after that variable has 
been reached.  If necessary, I would be happy to see what I can come up 
with here and then post it to the mailing list.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110411/f14bbeae/attachment.html>


More information about the fpc-pascal mailing list