时间选项不起作用



我试图测量执行时间,并用以下命令格式化:

time -f "%e" ./1 1000 1
-f: command not found
real    0m0.066s
user    0m0.044s
sys 0m0.023s

但这样的命令有效:

/usr/bin/time -f "%e" ./1 1000 1
31245 212 443
0.00

我试图确定另一个时间的位置,但所有时间都显示在/usr/bin/time

which time
/usr/bin/time

whereis time
time: /usr/bin/time /usr/bin/X11/time /usr/include/time.h /usr/share/man/man7/time.7.gz /usr/share/man/man2/time.2.gz /usr/share/man/man1/time.1.gz

type -a time
time is a shell keyword
time is /usr/bin/time

如何定义另一个时间的位置?

bash shell的用户需要使用显式路径才能运行外部时间命令,而不是shell内置变量。系统上如果时间安装在/usr/bin中,则第一个示例将变为

   /usr/bin/time wc /etc/hosts

注意:一些shell(例如bash(1))有一个内置的时间命令提供的功能少于此处描述的命令。到访问real命令时,您可能需要指定其路径名(类似/usr/bin/time)。

http://man7.org/linux/man-pages/man1/time.1.html

最新更新