i have the following problem that i would need your assistance to solve.
I have a function lets call it "fun"
, and i want to time how much time the function needs to be run, so i have this line added in the script:
time fun;
So like this, it will print also the time that the function needed to run. Point is that i want to redirect the output of the time
into a variable, so i can manipulate it later as i see fit. My failed tries already:
TIME=`time fun`
time fun | tail -3
etc..
Does anyone know how this can be done, so for example the desired result would be:
somehow add the time output in TIME variable.
so if i would echo $TIME
I would get result like this,
real 0m0.45s
user 0m0.35s
sys 0m0.00s
Thank you for your time!!
P.S.
I run the script on ksh, on an oracle solaris system.