![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Output to file but append rather than overwrite? | Sepia | UNIX for Dummies Questions & Answers | 2 | 06-19-2009 06:44 AM |
| how to grep and compare timestamp in a file with the current date | achu | AIX | 1 | 05-25-2009 09:05 AM |
| how to grep and compare timestamp in a file with the current date | achu | AIX | 1 | 05-25-2009 08:20 AM |
| Append Output to another file in Perl | Raynon | Shell Programming and Scripting | 7 | 09-03-2008 03:29 AM |
| Append output to file | ayhanne | Shell Programming and Scripting | 3 | 10-24-2007 12:30 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
|
||||
|
Quote:
That is putting the date before the grep result - is there a way to switch it around and maybe separate them by a comma? |
|
||||
|
Thanks but that is now doing:
,Thu Jun 25 13:04:59 BST 2009count: 3 Where 'count 3' should have four words infront of it! I've tried changing the order of sed "s/$/,$(date)/" around but that doesn't seem to help. edit: doesnt seem to be writing the date when its done as a cronjob. Just has $(date),monkey Last edited by Sepia; 06-25-2009 at 08:25 AM.. |
|
|||||
|
Quote:
try: sed "s/\$/,$(date)/" Quote:
|
![]() |
| Bookmarks |
| Tags |
| timestamp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|