Elapsed time ?
Ben Stringer
ben at burbong.com
Sun Mar 12 09:43:41 UTC 2006
On Sun, 2006-03-12 at 02:38 -0500, M. Lewis wrote:
> I'm trying to get the elapsed time. The following gives me '1', however
> I would like it to give me 1.98333333. Where am I missing the boat?
>
>
> #!/bin/sh
>
> TIME1=`date +%s`
> echo $TIME1
> sleep 119
> TIME2=`date +%s`
> echo $TIME2
>
>
> ELTIME=$[ ($TIME2 - $TIME1)/60 ]
"bc" has better precision. Try this instead:
ELTIME=$( echo "scale=10; ($TIME2 - $TIME1)/60" | bc -l)
Cheers, Ben
> echo $ELTIME
Ben Stringer ===== ben at burbong.com
==================================
More information about the fedora-list
mailing list