Using bc in bash script
Charles Howse
chowse at charter.net
Thu Aug 14 08:46:55 PDT 2003
Hello List,
I've migrated from Redhat Linux 9 to FreeBSD 4.8-RELEASE, character mode
- no gui.
I'm trying to calculate the number of seconds between $start_time and
$end_time in a bash script.
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
Then I want to: et=`bc $end_time - $start_time` to get the number of
seconds or fractions of seconds elapsed.
That's not working, bc is printing: file 1085492365 not available
>From what I've read in man bc, it's probably assuming those variables
are files.
I've read man bc, but I'm afraid it's beyond me (makes gesture with hand
passing over top of head).
What is the proper way to get the elapsed time here?
If the answer is in man bc, would someone please be kind enough to point
out the section so I can re-read it.
Thanks,
Charles
More information about the freebsd-questions
mailing list