updates only

Hi,
I have a file called Data-today.Txt that is updated every 5 minutes.

# cat '/root/Desktop/window/'`date +%b%Y`'/Data-'`date +%d%m%y`'.Txt' > /root/temp.txt

I want to read it every hour and findout the changes and process only those lines added since the last check.
I tried diff but did not get what I want.

At 9:56 A. M. the file looked:
This is line one
This is line two

At 10:00 A. M. I processed these two lines.

At 10:05 A. M. the original file will look like:
This is line one
This is line two
This is line three

at 11:00 A. M. I want to process only the newly added line i.e.
This is line three

Any help will be appreciated.

Regards,
Shantanu Oak

Can the file change anywhere? Or can lines only be added to it? If lines can only be added to it, just keep track of the last line number:

wc -l <filename> >/root/lastcheck-line.dat

Then a while later, do:

read L </root/lastcheck-line.dat
awk "NR==$L,0" <filename>  >/root/temp.txt

Once you're done, you can print the length again. You can do it altogether this way:

L=1; test -s /root/lastcheck-line.dat && read L </root/lastcheck-line.dat
awk "NR==$L,0 { print } END { print NR >'/root/lastcheck-line.dat' }" <filename>  >/root/temp.txt