Hello all,

I am looking for write a small script to read from a log file, and paste the lines in that are NEW since the last display.

Ideally i will run this on a console called by an existing bash script.

There is a cron job that is running that logs what it's doing (wow! i know, amazing!)

..

What I would like to do is parse the last lines of this log (assuming popen tail -n 20 logfile)

And .. if the log file has changed, display only the lines that have not been displayed.

Looking for any ideas anyone may have, code is a would-be-nice but absolutely not required.

Thanks in advance

    if you want only the lines that have changed, you might consider storing copy of the log file and then using diff to compare the two files.

    If you want to know what has changed, you need to somehow keep track of what was in the file before. Other options might be a line count. Or scanning the contents of the log and looking for reliable information like entry dates to compare.

      Write a Reply...