gpt4 book ai didi

linux - 如何在 Mac OS X 下重定向时间命令输出

转载 作者:太空狗 更新时间:2023-10-29 11:15:52 25 4
gpt4 key购买 nike

有几篇文章讨论了将时间命令输出重定向到文件。例如

(time my_program) 2> out

{ time my_program ; } 2> out

它们可以在 Linux 下工作,但不能在我的 Mac OS X 机器上使用 Darwin 内核版本 11.2.0。

(time my_program) 2> out
Badly placed ()'s.

{ time my_program ; } 2> out
{: Command not found.
}: Command not found.

time --version
--version: Command not found.
0.000u 0.000s 0:00.00 0.0% 0+0k 0+0io 0pf+0w

/usr/bin/time --version
/usr/bin/time: illegal option -- -
usage: time [-lp] command.

在我的Mac机下,有shell内置的time/usr/bin/time。它们都不提供 -o 选项。因为我的程序运行了几天,我想给它计时,在Mac OS X下如何将time的输出重定向到一个文件?

最佳答案

我意识到这真的很晚,但以下命令对我有用。

{ time ls > command.output 2>&1 ; } 2> time.out

关于linux - 如何在 Mac OS X 下重定向时间命令输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9388678/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com