Ubuntu – Why does running `time` and `/usr/bin/time` give different results

command lineenvironment-variablestime-command

Why does running time and /usr/bin/time give different results?

/usr/bin/time

thomas@tbdesktop:~$ /usr/bin/time -f "Elapsed time:%E" wc /etc/hosts
  9  25 224 /etc/hosts
Elapsed time:0:00.04

time

thomas@tbdesktop:~$ time -f "Elapsed time:%E" wc /etc/hosts
-f: command not found

real    0m0.079s
user    0m0.052s
sys 0m0.024s

My path is as follows. As far as I can see, there is only one time executable in the path.

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:~$ 

Best Answer

Because time and /usr/bin/time run different code. In order to determine it, do the following:

type time

It will show you that:

time is a shell keyword

Thus, it doesn't run /usr/bin/time if you simply call time.

They are different things...