Reputation: 881
I was trying to do this to dump all the output from command line to time.txt file as it is needed for my script.
(time echo "hi") > time.txt
What I observed is output of time
command is going to terminal.
real 0m0.000s
user 0m0.000s
sys 0m0.000s
and output of echo command is redirected to time.txt
$ cat time.txt
$ hi
Why is it so ?
I'm having hard time to understand this.
How can I redirect output of time
command to a file ?
I'm using ubuntu14.04 in case it matters.
In Is there a way to redirect time output to file in Linux there is one answer which redirects EVERYTHING to time.txt
.
But in my case I just want time.txt
to contain just the output of the time
command, NOT the output of the echo
.
Upvotes: 1
Views: 295
Reputation: 289775
Not very sure why this post got reopened.
As seen in Is there a way to redirect time output to file in Linux, you need to use:
{ time echo "hi" ; } 2> time.txt
Upvotes: 1