[olug] Doing math in /bin/bash

Kevin D. Snodgrass kdsnodgrass at yahoo.com
Sat May 7 14:48:00 UTC 2011


I'm trying to do a calculation in a bash script.  Looked at dc, but looks more complicated than it's worth.  Then tried gcalctool.  I get exactly what I want except for one thing, I just need the "whole" number part.  I.e., (a/b)*c mod 1.

Tried:
declare -i COUNT
COUNT=`gcalctool -s $A*$C/$B`

Was hoping it could be that easy. :-)


Any nifty ideas?

Kevin D. Snodgrass




More information about the OLUG mailing list