Using bc in bash script

Stephen Hilton nospam at
Thu Aug 14 10:23:40 PDT 2003

On Thu, 14 Aug 2003 12:11:55 -0500
"Charles Howse" <chowse at> wrote:

> > Charles,
> > 
> > This will set bc precision to 5 decimal places:
> > 
> > et=`echo "scale=5 ; $end_time - $start_time" | bc`
> Ohhh, I was really hoping on that one...but no, it still reports 0
> seconds.

Sorry I jumped the gun there, the scale is needed for this to work 
but the "date +%s" willonly resolve into whole seconds after reading 
the date man page.

I sure am curious as to how to solve this also, the /usr/bin/time 
command man page says this:

     The time utility executes and times the specified utility.  After the
     utility finishes, time writes to the standard error stream, (in seconds):
     the total time elapsed, the time used to execute the utility process and
     the time consumed by system overhead.

So that looks like seconds only also.

A quick browse through "man sh" and "man bash" look like their 
builtin time commands also resolve to seconds.


Stephen Hilton
nospam at

More information about the freebsd-questions mailing list