The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-25-2009
Sepia Sepia is offline
Registered User
  
 

Join Date: Apr 2007
Location: England
Posts: 49
Question Append file with grep output but add timestamp?

I've setup a cron job that greps a file every five minutes and then writes (appends) the grep output/result to another file:

grep "monkey" zoo.log | tail -1 >> cron-zoo-log

Is there any way I can add the date and time (timestamp) to the cron-zoo-log file for each time a new line was added?

At the moment the cron-zoo-log just looks like this:

monkey house
monkey car

Could I get it to be:

monkey house 2009-01-01:16:54:00
monkey car 2009-01-01:17:01:00

Thank you.