It may be a newbie's question, but I don't understand how this is configured and why the output format of time
command is different in these two cases:
if used via time
, the output is three rows with basic info
$ time sleep 1
real 0m1.003s
user 0m0.000s
sys 0m0.000s
then I can check out which binary is used
$ which time
/usr/bin/time
and call it directly to get output in a completely different format, with much more info
$ /usr/bin/time sleep 1
0.00user 0.00system 0:01.00elapsed 0%CPU (0avgtext+0avgdata 2000maxresident)k
0inputs+0outputs (0major+77minor)pagefaults 0swaps
there are no aliases related to time
$ alias | grep time
$
I'm running Ubuntu 16.04
.
Best Answer
The first one is the
bash
's own builtin keywordtime
(compiled withbash
), and the second one is the external executabletime
(/usr/bin/time
, comes with thetime
package).Also,
which
can't show the shell's builtin commands or keywords as it just searches throughPATH
, you need to usetype
for that. Being a shell builtin itself,type
can additionally check for shell's internal entities (and alsoPATH
), so you can spot the difference by:Here:
The first one will be executed if you just use
time
. You can also get which is being executed by just usingtype
(without-a
):The
-a
tellstype
to search in shell's internal entities and also inPATH
i.e. search in all possible sources.If for some reason you need the external one, use any one of: