我如何重定向“时间"输出?命令? [英] How can I redirect the output of the "time" command?
本文介绍了我如何重定向“时间"输出?命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图重定向time命令的输出,但是我不能:
I tried to redirect the output of the time command, but I couldn't:
$time ls > filename
real 0m0.000s
user 0m0.000s
sys 0m0.000s
在文件中,我可以看到ls
命令的输出,而不是time
的输出.
请解释一下,为什么我做不到,以及如何做到这一点.
In the file I can see the output of the ls
command, not that of time
.
Please explain, why I couldn't and how to do this.
推荐答案
您可以使用以下方式重定向时间输出,
you can redirect the time output using,
(time ls) &> file
因为您需要将(time ls)作为一个命令,以便可以使用花括号.
Because you need to take (time ls) as a single command so you can use braces.
这篇关于我如何重定向“时间"输出?命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文