I want to use the time
bash command to measure the execution time of a script, and to save only the real time in a file, with a specific precision. Here is what I have that works:
{ time TIMEFORMAT='%4R' <script> 2> <script>.stderr ; } 2>> time.txt
But I'm wondering whether there is a shorter way of doing this, or is it possible to use tee
?
Is a shorter way of saving
I'm wondering whether there is a shorter way of doing this
Yes, just remove the spaces and unneeded quotes. Also, as subshell is most probably not a problem, you can change {
for (
to save needed space after {
and after }
.
(TIMEFORMAT=%4R time cmd 2>cmd.stderr)2>>time.txt
It is, if I'm counting right, 8 characters shorter.