Q:

Redirecting the output of time command to a file

I just found, that the following doesn't work on my Ubuntu 16.04 the way it should:
$ time >file 2>&1

real    0m0.000s
user    0m0.000s
sys     0m0.000s
$ cat file
$

Output goes to terminal, the file is empty, though with 2>&1 (descriptor 2 redirect to address of descriptor 1) STDERR is supposed to go where STDOUT goes. I've been looking for existing topics on this subject, and in description of a more complicated problem such a simple one as here is usually mentioned that it does well. Why could it be misbehaving like this?
UPD: got the answer, time is a built-in command in BASH. Maybe someone puzzles over exact same thing (likely those who learn Unix with old book of Kernighan and Pike).

A:

You're using bash, which indeed has a built-in keyword called time which functions in a similar way.
Instead of using the built-in time (bash) command, you can access the installed binary (if any) like /usr/bin/time -p [command] >file 2>&1. Which will exactly do what you expect.
Please note the -p option, which is needed for the "portable output format" you've seen above.
Also please take a look at the manpage: man time.

