Con Perl:
command 2>&1 | perl -pe 'print scalar(localtime()), " ";'
Con bostezo:
command 2>&1 | awk '{ print strftime(), $0; fflush() }'
Reemplazar command
con tail -f logfile
para su ejemplo específico. O tal vez podría redirigir el stdout/stderr del programa original a la tubería anterior.
Prueba
tail -f logfile | while read line; do echo `date` "$line" ; done
Puedes probar esto
cat /etc/motd | xargs -d"\n" -I {} date +"%Y-%m-%d %H:%M:%S {}"
Salida de ejemplo:
2013-02-26 15:13:57 2013-02-26 15:13:57 The programs included with the Debian GNU/Linux system are free software; 2013-02-26 15:13:57 the exact distribution terms for each program are described in the 2013-02-26 15:13:57 individual files in /usr/share/doc/*/copyright. 2013-02-26 15:13:57 2013-02-26 15:13:57 Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent 2013-02-26 15:13:57 permitted by applicable law.