How to read log files from last read

Hi
i am looking a way to look at a log file(log.txt) from the last time I've read it.
However after some days the main log file(log.txt) is rename to (log.txt.1).
So now i will have two log files as below.

log.txt.1
log.txt

Now, i have to read the log from the point where i have left the last read.
I can do this by storing the last line no# read in seperate file and and start reading the log file from that line, however if the log files is renamed(backed up), this logic will not work.

Any suggesstion.

Is there a time stamp in the log entries?

Yes, it has the timestamp in the below format.

2012-02-12 07:01:04 some string....

Then surely the correct approach would be to remember the last read time stamp, grep for it, open that file ...

1 Like