in reply to Re^4: Append the timestamp before and after the data in the logfile
in thread Append the timestamp before and after the data in the logfile

There's an important difference. AFAIK 'time' is not a program, but a shell command. It prints to STDERR, so you can't capture it with a plain '>' redirection, but even a '2>' won't do, since you have to capture the output of the whole pipeline:
$ time perl -le 'print "foo"; sleep 1' >/dev/null real 0m1.017s user 0m0.003s sys 0m0.002s $ time perl -le 'print "foo"; sleep 1' 2>/dev/null foo real 0m1.012s user 0m0.003s sys 0m0.004s $ (time perl -le 'print "foo"; sleep 1') >/dev/null real 0m1.012s user 0m0.002s sys 0m0.004s $ (time perl -le 'print "foo"; sleep 1') 2>/dev/null foo $ { time perl -le 'print "foo"; sleep 1'; } 2>/dev/null foo
  • Comment on Re^5: Append the timestamp before and after the data in the logfile
  • Download Code