Grep the Content of a LOG File which has latest Date and Time

Hi All,

Need a small help. I have a log file which keeps updating for every Minute with multiple number of lines. I just want to grep few properties which has latest Date and Time to it. How do i do it?

I wanted to grep a property by name "Reloading cache with a maximum of" from the "123.log" which has some thousands of lines in it

When i use the command "cat 123.log | grep 'Reloading cache with a maximum of' " it fetches the data something like this

"2011-08-29/08:07:44.219 INFO EJB-Timer-0a6c6b1d-563b-4c3a-a756-c854ab44364e[target=jboss.j2ee:ear=ear-xxxx-xxx-xxxxx.ear,jar=xxx-xxxxx-xxx-253134.jar,name= / Reloading cache with a maximum of 10000 loads

2011-08-29/08:08:44.230 INFO EJB-Timer-0a6c6b1d-563b-4c3a-a756-c854ab44364e[target=jboss.j2ee:ear=ear-xxxx-xxx-xxxxx.ear,jar=xxx-xxxxx-xxx-253134.jar,name= / Reloading cache with a maximum of 10000 loads

2011-08-29/08:09:44.242 INFO EJB-Timer-0a6c6b1d-563b-4c3a-a756-c854ab44364e[target=jboss.j2ee:ear=ear-xxxx-xxx-xxxxx.ear,jar=xxx-xxxxx-xxx-253134.jar,name= / Reloading cache with a maximum of 10000 loads "

I always wanted my script to get the last row which has latest date and time in it.

Can someone please HELP its urgent..........

Try using " tail -1 123.log"

The log keeps scrolling and so i can not use the tail -1

What about:

tail -f Log_File

for last row by property -

cat 123.log | grep "Reloading cache with a maximum of"|tail -1

---------- Post updated at 05:07 PM ---------- Previous update was at 05:02 PM ----------

another method for latest date -

export CURRDATE='date +%Y-%m-%d/%H:%M:%S'

cat 123.log|grep $CURRDATE|tail -1

it will show you the last line one which the time CURRDATE was created. you can add some property to get the desired result also.