View: Redirecting output of the bash keyword time

  1. 5 months ago by skanx
    time command > timelog doesn't work, because time outputs to stderr
    time command 2> timelog doesn't work either, because time actually is a bash keyword, and it's always run in a subshell
    
    Redirecting the output of time can be achieved by executing the whole command in a block, then redirecting its output:
    { time command; } 2> timelog
    
    Note: Linux also provides a time binary (/usr/bin/time), but with a different output (and might be less efficient ?)

0 comment about "Redirecting output of the bash keyword time"