tmh766 Posted March 1, 2007 Share Posted March 1, 2007 How can you read only the last line of a file without reading the entire file? I have a log and only need the most recent line of data which is at the end. Quote Link to comment Share on other sites More sharing options...
btherl Posted March 1, 2007 Share Posted March 1, 2007 If you are running on unix, you can do $last_line = exec("/usr/bin/last $file"); Don't do that if $file was passed in as an argument to the script, as that would be a major security risk. Quote Link to comment Share on other sites More sharing options...
tmh766 Posted March 1, 2007 Author Share Posted March 1, 2007 Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.