I have to write down a script that execute this command
Code:
time ./my_program
and insert only the value near
Code:
user
in a variable.
I will explain more exactly it:
when I execute the command "time ./my_program" the shell print this answer:
Code:
Random number from 1 to 100: 1078793234
real 0m0.095s
user 0m0.000s
sys 0m0.008s
In the first line there is the result making by my_program
and then there are 3 lines reporting the time that the OS spends to execute it.
My problem is :
I have to use only the value reported near "user".
I tried to do it in this way:
Code:
var=$(time ./my_program)
var2=$(cut -f 1,2 -d'r' ${var})
echo "ciao ${var2}"
but it doesn't work!
Can you help me please?
Thank you very much