0

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

2 Answers2

2

If you want to use bc, then:

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

Or:

answer=$(expr $varnameX % $num1 )
Prvt_Yadav
  • 5,882
0
answer=`expr $varnameX % $num1`
kevlinux
  • 389