Assume a shell script writes without timestamp info:
myscript.sh
bla
mumble
how long it took to complete bla? and mumble? no clue. You could hack the script to add a timestamp for each echo, but that's not practical. Workaround:
vi timestamp.sh
chmod 775 timestamp.sh
now you can use it this way:
myscript.sh | ./timestamp.sh
20140415-145529 bla
20140415-145529 mumble
myscript.sh
bla
mumble
how long it took to complete bla? and mumble? no clue. You could hack the script to add a timestamp for each echo, but that's not practical. Workaround:
vi timestamp.sh
#! /bin/bash
while read line
do
echo `date +"%Y%m%d-%H%M%S"` $line
done
chmod 775 timestamp.sh
now you can use it this way:
myscript.sh | ./timestamp.sh
20140415-145529 bla
20140415-145529 mumble