So I’m using /usr/bin/time to measure my program, and I’m doing multiple runs of the same program so I can gather results. The problem with doing multiple executions and using /usr/bin/time at the same time is that it’ll print out that giant chunk of information multiple times, and I don’t want to scroll, copy, and paste my results into a text file. I’d rather have the command line do it for me.
Originally, I thought the command was something like:
/usr/bin/time -v sudo ./programname >> timeoutput.txt
But as far as I know, >> is used for stdout, so it won’t work in this case.
If you just want to append the standard error of
time(which is the handle it uses for outputting the time information) to a file, you can use:The
2>>...bit redirects standard error rather than standard output and the()ensures that the redirection applies totimerather than the command you’re running.Of course, that won’t stop any error output from the program you’re timing from showing up in the file, if you want to guarantee that, you need something like:
This will ensure that no error output from the command trickles out to interfere with the error output of
time.In the above examples, I’ve used
sleep 1for the command but you should just replace that with whatever command you’re trying to run.