庆典时间输出处理 [英] bash time output processing
本文介绍了庆典时间输出处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道时间
将计时统计输出发送到标准错误
。但不知何故,我无法抓住它无论是在bash脚本或到通过重定向一个文件:
I know that time
will send timing statistics output to stderr
. But somehow I couldn't capture it either in a bash script or into a file via redirection:
time $cmd 1>/dev/null 2>file
$output=`cat file`
或者
$output=`time $cmd 1>/dev/null`
我只对感兴趣的时机,而不是命令的直接输出。我读过一些帖子overhere但仍没有运气找到一个可行的解决方案。有什么建议?
I'm only interested in timing, not the direct output of the command. I've read some posts overhere but still no luck finding a viable solution. Any suggestions?
谢谢!
推荐答案
尝试:
(time $cmd) 1>/dev/null 2>file
让(时间$ CMD)
在子shell环境中执行,然后你可以重定向输出。
so that (time $cmd)
is executed in a subshell environment and you can then redirect its output.
这篇关于庆典时间输出处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文