Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Aug 2003 18:45:03 +0200
From:      Alexander Haderer <alexander.haderer@charite.de>
To:        Kirk Strauser <kirk@strauser.com>, freebsd-questions@freebsd.org
Subject:   Re: Using bc in bash script
Message-ID:  <5.2.0.9.1.20030814183506.01a82ef8@postamt1.charite.de>
In-Reply-To: <87d6f89oya.fsf@pooh.honeypot.net>
References:  <001a01c3627e$487d7a10$04fea8c0@moe> <001a01c3627e$487d7a10$04fea8c0@moe>

next in thread | previous in thread | raw e-mail | index | archive | help
At 11:35 14.08.2003 -0500, Kirk Strauser wrote:
>At 2003-08-14T16:08:21Z, "Charles Howse" <chowse@charter.net> writes:
>
> > Can I refine it to give me something like: .784 seconds?
>
>Use "bc -l" instead of bc.  That should do it.

Yes, but not in the context mentioned before:

 > > > Start_time=`date +%s` # Seconds past midnight at start of script
 > > > [ do lots of stuff ]
 > > > End_time=`date +%s`   # Seconds past midnight at end of script

et=`echo "$end_time - $start_time" | bc -l`

Here bc -l will not really help, because date +%s returns whole seconds :-(

BTW: %s are seconds since epoch

Alexander



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5.2.0.9.1.20030814183506.01a82ef8>