how to print current(not stagnant value) with each row using awk (or sed whatever...)
Rajeev Prasad
rp.neuli at yahoo.com
Thu Apr 18 18:03:07 UTC 2013
I am monitoring a log which does not print timestamps, so i am doing tail -f on the log, but I want to print time in front of each entry as it happend /added in the log. I tried below, but see it has problem that it calculates the date value once and use it for all new records (which will be on different time added to lgo file)
OS = solaris 10
$echo "`date`" >> file1
$tail -f file1| awk '{print d,$0}' "d=$(date)"
Thu Apr 18 17:57:18 GMT 2013 Thu Apr 18 17:51:32 GMT 2013
Thu Apr 18 17:57:18 GMT 2013 Thu Apr 18 17:52:01 GMT 2013
Thu Apr 18 17:57:18 GMT 2013 Thu Apr 18 17:52:53 GMT 2013
Thu Apr 18 17:57:18 GMT 2013 Thu Apr 18 17:52:58 GMT 2013
Thu Apr 18 17:57:18 GMT 2013 Thu Apr 18 17:57:25 GMT 2013
Thu Apr 18 17:57:18 GMT 2013 Thu Apr 18 17:57:32 GMT 2013
Thu Apr 18 17:57:18 GMT 2013 Thu Apr 18 17:57:37 GMT 2013
Please note the 'date' stored in variable d does not change!!!
I want to print current datetime with each row, as the datetime would be at that moment when row was spitted out from file1
I would appreciate any help.
ty.
More information about the ubuntu-users
mailing list