如何重定向“时间"的输出?命令? [英] How can I redirect the output of the "time" command?

查看:30
本文介绍了如何重定向“时间"的输出?命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重定向时间命令的输出,但我不能:

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.

推荐答案

您可以使用,

(time ls) &> file

因为您需要将 (time ls) 作为单个命令,以便您可以使用大括号.

Because you need to take (time ls) as a single command so you can use braces.

这篇关于如何重定向“时间"的输出?命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆