I want to know how long a program running, so I tried "/usr/bin/time ./program > /dev/null". But soon I found it displays program's output to stderr. I tried "/usr/bin/time ./program > /dev/null 2>&1" then, but /usr/bin/time's output not appear. So my question is, how to ignore program's output, and keep time's output.
Thanks a lot.
(Unable to comment)
It might be nicer to use a subshell:
Or better yet a compound construct:
Use the
-o
flag to send the output from time to something else thenstderr
. For example, if you still want it on screen:Or, if you want output on
stdout
very badly:or similar. However, now you're also measuring the shell's time to start the process, which may or may not be a problem.