wert
wert

Reputation: 55

linux time result is not written to file

i am using debian. running my program with time command and want the result of time written to a file, doing as follows:

time ./myprog > out.asc

./myprog's output is written to out.asc but not the time's result. is there any way to send the time's output also to out.asc? thanx!

Upvotes: 4

Views: 1039

Answers (3)

iniju
iniju

Reputation: 1094

Try (time ./myprog) >out.asc 2>&1

Upvotes: 1

R Samuel Klatchko
R Samuel Klatchko

Reputation: 76581

time always writes to stderr. To save this with bash, use 2>&1 to write to the same place as stdout (you need the parentheses so you get the stderr of time and not just the stderr of myprog):

(time ./myprog) > out.asc 2>&1

You could also have the timing information go to a separate file:

(time ./myprog) > out.asc 2> timing_info

Upvotes: 11

KenE
KenE

Reputation: 1805

(time ./myprog) > out.asc 2>&1

(from http://www.unix.com/unix-dummies-questions-answers/26277-redirect-time-output.html)

Upvotes: 1

Related Questions