I have the following bash command to tee script output to stdout and logfile. It works and I can see the live output. However the date is not changing. Is there any way to instruct exec to evaluate date in a dynamic way.
#!/bin/bash
LOGFILE="/tmp/te/script.log"
exec 1> >( stdbuf -e 0 -o 0 sed "s/^/$(date '+[%F %T]'): /" | tee -a ${LOGFILE}) 2>&1
echo "Started"
sleep 2
echo "Done sleeping"
sleep 2
echo "Another sleep"
sleep 2
echo "Done"
Thanks