0

This question already has an answer here:

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

marked as duplicate by G-Man, Community Mar 22 at 5:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

If you want to use bc, then:

answer=$(echo "$varnameX % $num1" | bc)
echo "the result is $answer"

Or:

answer=$(expr $varnameX % $num1 )
0
answer=`expr $varnameX % $num1`

Not the answer you're looking for? Browse other questions tagged or ask your own question.