hello everybody!
i want to post a question. So, I use the command 'time a.out' to time the duration of the program a.out. The return value of this function was:
real 0m4.116s
user 0m4.112s
sys 0m0.016s
What i want is! I try to find a way to get (NOT manually) the value of real time. For example 0m4.116s.
Can anybody help me!!!!
thanx in advance!
time a.out|awk '/real/{print $2}'
Hello Nicos,
I think what you might be seeing is a confusion between the Bash builtin command 'time' and the GNU program time.
If you type
time -v aout
does it return an error? (on my system it is:
bash: -v: command not found
)
If it does return an error - try this:
`which time` -v aout
If you get lots of verbose info then you are confusing the builtin with the program.
Try to explicitly invoke the time program first by finding it.
Run
which time
which for me yields:
/usr/bin/time
When you run it use the full path of the command.
ON my system to do what you are trying to do, I would type:
/usr/bin/time -f %e aout
Now if aout sends alot of stuff to stdout or stderr you might have to redirect it but otherwise the result will be just he elapsed time.
For example
$ /usr/bin/time -f %e sleep 4
4.00
yrs
Michael