I'm writing a script and I would like to pass the results from bc
into a variable. I've declared 2 variables (var1
and var2
) and have given them values. In my script I want to pass the results from bc
into another variable say var3
so that I can work with var3
for other calculations. So far I have been able write the result to a file which is not what I'm looking for and also I've been able to echo the result in the terminal but I just want to pass the result to a variable at moment so that I can work with that variable.
echo "scale=2;$var1/var2" | bc