为什么运行time
会/usr/bin/time
产生不同的结果?
/usr/bin/时间
thomas@tbdesktop:~$ /usr/bin/time -f "Elapsed time:%E" wc /etc/hosts
9 25 224 /etc/hosts
Elapsed time:0:00.04
时间
thomas@tbdesktop:~$ time -f "Elapsed time:%E" wc /etc/hosts
-f: command not found
real 0m0.079s
user 0m0.052s
sys 0m0.024s
我的路径如下。据我所知,time
路径中只有一个可执行文件。
thomas@tbdesktop:~$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
thomas@tbdesktop:~$ find / -name time 2> /dev/null
/sys/devices/pnp0/00:03/rtc/rtc0/time
/sys/module/printk/parameters/time
/var/lib/dkms/virtualbox/4.1.12/build/common/time
/var/lib/doc-base/documents/time
/usr/src/linux-headers-3.2.0-30/kernel/time
/usr/src/linux-headers-3.2.0-31-generic/include/config/sr/report/time
/usr/src/linux-headers-3.2.0-31-generic/include/config/generic/time
/usr/src/linux-headers-3.2.0-31-generic/kernel/time
/usr/src/virtualbox-4.1.12/common/time
/usr/src/linux-headers-3.2.0-29/kernel/time
/usr/src/linux-headers-3.2.0-30-generic/include/config/sr/report/time
/usr/src/linux-headers-3.2.0-30-generic/include/config/generic/time
/usr/src/linux-headers-3.2.0-30-generic/kernel/time
/usr/src/linux-headers-3.2.0-29-generic/include/config/sr/report/time
/usr/src/linux-headers-3.2.0-29-generic/include/config/generic/time
/usr/src/linux-headers-3.2.0-29-generic/kernel/time
/usr/src/linux-headers-3.2.0-31/kernel/time
/usr/bin/time
/usr/share/doc/time
/usr/share/doc-base/time
thomas@tbdesktop:~$
答案1
因为time
和/usr/bin/time
运行不同的代码。为了确定它,请执行以下操作:
type time
它将向您显示:
time is a shell keyword
/usr/bin/time
因此,如果您简单地调用,它就不会运行time
。
它们是不同的东西...