January 2004
Intermediate to advanced
368 pages
7h 25m
English
One of the most commonly used sequences in script writing is $(( )), which lets you perform calculations using various rudimentary mathematical functions. This sequence can be quite useful, most commonly when incrementing counter variables, and it supports addition, subtraction, division, remainder, and multiplication, though not any sort of fractional or decimal value. Thus, the following command returns 0, not 0.5:
echo $(( 1 / 2 ))
So when calculating values that need better precision, you've got a challenge on your hands. There just aren't many good calculator programs that work on the command line. Except, that is, for bc, an oddball program that few Unix people are taught. Billing ...
Read now
Unlock full access