0

I would like to ask what the output of time statistics for command execution belongs to (which file description) since it is neither 1(stdout) nor 2(stderr) !
And why so ?

#
#
#
# time date 1>/tmp/date_1.out 2>&1

real    0m0.00s
user    0m0.00s
sys     0m0.00s
#
#
#
# cat /tmp/date_1.out
Mon Dec 10 11:20:36 BEIST 2017
#
# 
#
lylklb
  • 303

1 Answers1

2

It belongs to neither stdout nor stderr of date. It belongs to stderr of the time. Observe:

$ ( time date 1>/tmp/date_1.out 2>&1 ) 2>time.out
$ cat time.out

real    0m0.002s
user    0m0.000s
sys     0m0.000s

time executes date 1>/tmp/date_1.out 2>&1. The output of time is not subject to the redirections that are applied to the output of date. This is possible because time is not a normal command: time is a shell keyword:

$ type time
time is a shell keyword

Thus, it gets to play by different rules.

John1024
  • 74,655
  • Then,I'd like to know the relationship & rule between shell reserved word and its output redirection! – lylklb Dec 13 '17 at 03:20
  • @lylklb There is no universal answer for shell keywords. The answer demonstrates how to redirect the output of time. – John1024 Dec 13 '17 at 03:29
  • Anyone has more explanation or good idea about the relationship & rule for the output redirection of shell reserved word ?! – lylklb Dec 30 '17 at 04:50
  • @lylklb Are there any specific words that you are interested in besides time? – John1024 Dec 30 '17 at 05:08
  • I have a little understand what you mean, and I also think there is just only the time reserved word that has a standalone command's output character ! – lylklb Dec 30 '17 at 07:17