in reply to How can I grab the last 2 lines of a file?
Since its byte and not line based you'll need to read a sufficiently big trailing chunk into a line array and take the last two entries. (and if the chunk wasn't big enough try a bigger one )
Search the archives, similar questions have been asked before and adjust the code to your needs.
> Ideally, I would like to store the second-to-last line to ...
Ideally someone would bring me now a banana split and a hot espresso to my sofa...
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
... or a strudel with vanilla ice cream... Hmm! :)
No espresso yet? Hence no tip! :(
But at least a link http://www.google.com/search?q=read+last+n+lines+of+a+file+perl+site:www.perlmonks.org
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I grab the last 2 lines of a file?
by 1s44c (Scribe) on Jul 27, 2014 at 09:47 UTC |