On Dec 4, 9:28 am, pjodrr <pjo...@gmail.com> wrote: > Hello, > > how can I prefix every line of output of some command with a > timestamp? I thought like this: > > $ exec 3> >(while read line; do echo "$(date): $line"; done) > $ seq 4 >&3 > Friday, December 4, 2009 4:20:29 PM MET: 1 > $ Friday, December 4, 2009 4:20:29 PM MET: 2 > Friday, December 4, 2009 4:20:29 PM MET: 3 > Friday, December 4, 2009 4:20:29 PM MET: 4 > > please note that the prompt ($) returns before the command completes. > Why is the > process substitution asynchronous? > Does anybody know of a better way to accomplish this? > > Thanks, > > Peter
This should be in gnu.bash rather than gnu.bash.bug Would this work for you? while read line; do echo "$(date): $line $((num++))"; done