Home > bashism, linux, software > It’s about time

It’s about time

The tiny tool time everybody should know, measures execution time of a given command. For example:

time echo "test"

prints time information to the console. But what if you want to collect these statistics in a file? Linux man page say “-o FILE” is the way to do so. This will look like

time  -o file.log echo "test"

This FAILS not only on my machine with the error message “bash -o: unknown command” or equal. The key is to give the full path:

/usr/bin/time -o file.log echo "test"

The problem is, that “time” is used for different things. This leads to another cute tool called type. type gives information about the kind of a command.

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

As you can see “time” not only means the command. If somebody knows more about the “Why the hell is this so?”, feel free to post :D

Categories: bashism, linux, software Tags: , , , ,
  1. Willi
    June 17th, 2009 at 17:37 | #1

    time is a reserved word in bash used like the /usr/bin/time when using pipes. It then reports back on pipe termination the time consumption used by the pipe.

    that’s how far my knowledge concerning this goes – if anyone knows more – please indulge me, … ;)

  1. No trackbacks yet.