1

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.

Community
  • 1
  • 1
Vikram Dattu
  • 801
  • 3
  • 8
  • 24
  • 1
    `{ time echo "hi" ; } 2> t` redirects the output of `time` to `t`, whereas `hi` is printed in the output. Isn't this what you are looking for? – fedorqui May 12 '15 at 10:41

1 Answers1

1

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
Community
  • 1
  • 1
fedorqui
  • 275,237
  • 103
  • 548
  • 598