I want to do a simple coding by storing the product of calculation using command bc
into variable.
answer="$varnameX % $num1" | bc
echo "the result is $answer"
it did not show the product of calculation once i run the command
the answer is
I want to do a simple coding by storing the product of calculation using command bc
into variable.
answer="$varnameX % $num1" | bc
echo "the result is $answer"
it did not show the product of calculation once i run the command
the answer is
If you want to use bc
, then:
answer=$(echo "$varnameX % $num1" | bc)
echo "the result is $answer"
Or:
answer=$(expr $varnameX % $num1 )