1

I'm trying to redirect the result of "time" command in Cygwin to a file, and I'm not sure how to do it. I've tried time app.exe > /file/path/file.txt, (time app.exe) > /file/path/file.txt, time > /file/path/file.txt app.exe , and so on.. Frankly, whatever I could think of.

All of the above either output app.exe (which is just a stupid app that prints a few characters) to file.txt, and not the time it took to run..

also tried with -o, but it bash: -o command not found

So, how should I do it? And is the usage of a full path a problem?

1 Answer 1

3

There are two problems here, one is that time prints to STDERR (standard error) not STDOUT (standard output) so you will need to redirect that. This is done using this notation: 2>. The other problem is that time runs another command and you need to separate the two.

The solution is to use a subshell ( ) and you had it almost right:

(time app.exe ) 2> \file\path\file.txt

or

time ( app.exe ) 2> \file\path\file.txt
1
  • Never would have guessed that..
    – Ysch
    Sep 1, 2013 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .