Struggling to parse (bash) time command

后端 未结 5 733
甜味超标
甜味超标 2020-12-07 00:55

I\'m struggling to parse the output of the time command in bash - and even to stop it from printing out its output when I call it. This is my test code:

#!/b         


        
5条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 01:00

    The time command outputs the timing information to STDERR, which you aren't capturing or redirecting. So at the time of the assignment, that information is printed out to your console, while the $TIME variable gets the STDOUT of the command - which you redirected to /dev/null, so it's blank.

    Perhaps you should try to capture the STDERR of the command?

提交回复
热议问题