From: Niall O Broin (niall at domain linux.ie)
Date: Thu 10 May 2001 - 12:29:44 IST
And interesting question arosewhen I looked at Stephen Reilly's question
about NIC speed/duplex. Why can't the output from a time command be
redirected ? I ran the following little script to test my test :-)
#!/bin/sh
time rcp 10M bilbo: &
time rsh bilbo rcp 10m bagend: &
where 10M is a 10M file on bagend, and 10m is a 10M file on bilbo (don't get
all agitated about rsh/rcp - this is all on my HAN) and I eventually just
ran it as above, taking the larger real time as the total elapsed time. I
tried to redirect time's output, but failed miserably. Look at this
niall at domain bagend:~ >rm xx;time rcp 10M bilbo: >xx 2>&1
real 0m0.974s
user 0m0.000s
sys 0m0.130s
niall at domain bagend:~ >file xx
xx: empty
niall at domain bagend:~ >rm xx;time (rcp 10M bilbo:) >xx 2>&1
niall at domain bagend:~ >file xx
xx: empty
In each case, xx is created by the shell. In the first case, time's output
still appears on the screen. In the second case, with the subshell, no
output appeared. Now I've since read the time manual :-) (well, the info
page) which informed me about the -o option, but the same info page assured
me that time writes to stderr, so why doesn't redirecting stderr work ?
Aargh - -o didn't work. More RTFM (or rather, running the type command) and
I see that I'm actually running the bash command time. If instead I use
/usr/bin/time both -o and redirection work. There's very little mention of
time in the bash man page, and certainly nothing which would indicate that
it is immune to redirection.
Niall
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:10:15 GMT