Firstly, 'bc' is cool. But sometimes it can take most of a cold beer to figure out how to get it to understand what I'm trying to do. The other problem is that ' if [ $NumVar > 0 ]; then blah blah ..; fi' will often have the hidden side effect of creating all those wierd little files you see from time to time named '1' or '0' with nothing in them.
So .. I wrote a utility in C called 'decx' (decimal worx). It doesn't use standard math operators. Instead it uses alphabet operators similar to a -gt, -lte type of operator, but in uppercase and no dash is needed. Why? To keep from confusing bash. It does decimal comparisons, and decimal math. You can specify the precision you prefer (default is 1)
So attached is a tar.gz file with the C source and a simple bash testing script. Take a look at the code, compile on your machine, stick it in your my-applications/bin, and have fun with it.
- jafadmin
[Update] Guys I don't need advice on how to write shell scripts. I've been doing it since the 80's. On more different types of shells than I care to mention. On more different OS's than I care to mention. I've been writing C code even longer. But thanks