get_timestamp() {
  date "+%Y.%m.%d %H:%M:%S"
}
timestamp=$(get_timestamp)
timestamp=$(date "+%Y%m%d-%H%M%S")

# posix shell
command | while IFS= read -r line; do printf '[%s] %s\n' "$(date "+%Y-%m-%d %H:%M:%S")" "$line"; done

# gnu awk
command | gawk '{ print strftime("[%Y-%m-%d %H:%M:%S]"), $0 }'

# perl
command | perl -pe 'use POSIX strftime; print strftime "[%Y-%m-%d %H:%M:%S] ", localtime'

# python
command | python -c 'import sys,time;sys.stdout.write("".join(( " ".join((time.strftime("[%Y-%m-%d %H:%M:%S]", time.localtime()), line)) for line in sys.stdin )))'

# ruby
command | ruby -pe 'print Time.now.strftime("[%Y-%m-%d %H:%M:%S] ")'

# awk
command | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }'
