I'm writing a simple bash script. I have just started learning about writing these,
but I have found a need for something, so I set out to do it. The problem is with
division.
Here is my script:
Code:
#!/bin/bash
clear
z=256
echo "What is the Red value?"
read r
echo "What is the Green value?"
read g
echo "What is the Blue value?"
read b
r1=$((r/z))
g1=$((g/z))
b1=$((b/z))
echo "The values are now..."
echo "$r1, $g1, $b1"
The problem is that since most of the time, the ending values will be less then 1,
it gets rounded down to zero instead of a decimal. I want the output to be
fractional to 2 decimal places (example - 64/256 = 0.25)
The 2 beginners guides I have do not reference this. I tried searching on line in
advanced guides, but got lost... fast.
I'm sure it has to do with how I am having it caclulate r1, g1, & b1, but I can't find it.
Any script savy people out there willing to help?
Thanks in advance
-tw