This question shows research effort; it is useful and clear
1
This question does not show any research effort; it is unclear or not useful
Bookmark this question.
Show activity on this post.
我需要在 ksh 中使用 dot 命令作为“.my_function.sh”调用我的 shell 脚本。我还想使用 time 命令并将输出重定向到日志文件。没有“。” 命令,如果我使用“(time my_function.sh) 2>&1 | tee -a tmp.log”,一切都很好。但是,如果我使用“(time .my_function.sh) 2>&1 | tee -a tmp.log”,时间部分就会消失。任何人都可以让我如何输出时间部分吗?谢谢。
% cat my.sh
#!/bin/ksh
echo hi
% (time . my.sh) 2>&1 | tee my.log
hi
real 0m0.00s
user 0m0.00s
sys 0m0.00s
% cat my.log
hi
real 0m0.00s
user 0m0.00s
sys 0m0.00s