I noticed something odd when using the unbuffer command with time command. Here I just want to see how long takes to find a certain file in my system:

time find . -name unixstuff

output is :

0.011u 0.173s 0:00.38 47.3%     0+0k 0+0io 0pf+0w

but when I write unbuffer before this command output is :

0.01user 0.17system 0:00.38elapsed 47%CPU (0avgtext+0avgdata 4656maxresident)k
0inputs+0outputs (0major+338minor)pagefaults 0swaps

Note that 0.17s is expanded to 0.17system and other expansions of shorthand happened. I would like to know why this change of behaviour happens. I don't want an unpredictable output in my pipes.


It's because the time in the first command is a shell keyword. The time in the second command is the executable. See the type output of time:

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

The command unbuffer needs a program as argument not a shell keyword. It cannot interpret a shell keyword, this is a bash internal keyword.

And the difference in the output you see is the difference of those two implementations of the time command. Just use the abolute path in the first command that you have the same behavior as in the second one:

/usr/bin/time find . -name unixstuff
  • Alternatively, unbuffer bash -c 'time find . -name unixstuff' – Barmar Oct 15 '14 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.