I am trying to divide two image widths in a Bash script, but bash gives me 0
as the result:
RESULT=$(($IMG_WIDTH/$IMG2_WIDTH))
I did study the Bash guide and I know I should use bc
, in all examples in internet they use bc
. In echo
I tried to put the same thing in my SCALE
but it didn't work.
Here is the example I found in the tutorials:
echo "scale=2; ${userinput}" | bc
How can I get Bash to give me a float like 0.5
?
You can't. bash only does integers; you must delegate to a tool such as bc
.