The following chain of commands are to
ping with datestamp (UNIX),
convert the UNIX datestamp to more human-readable format, and
output to the terminal and a log file.
ping -D localhost 2>&1 | sed 's/^\[\([0-9]*\.[0-9]*\)\]\(.*$\)/echo "[`date -d @\1 +"%Y-%m-%d %H:%M:%S"`] \2"/e' | tee -a ping.log
Problem is that as written, the output seems to be buffered in chunks of almost a minute or ~50 lines, unlike the usual second-by-second and line-by-line output from ping.
What is causing the buffering and how can it be avoided?