I need to count variables, round to 2 and store to variable.
Example:
I have variable from array ${array[5]} and vat variable defined, I need to calculate simple
( $vat * ${array[5]} + ${array[5]} )
and store to variable pricevat.
I tried:
vat = 0.21
pricevat=$(echo "$vat * ${array[5]}" + ${array[5]} | bc -l)
(( pricevat=$vat*${array[5]}+${array[5]}))
But nothing works:
line 48: ((: pricevat=0.21*0.233+0.233: syntax error: invalid arithmetic operator (error token is ".21*0.233+0.233"
Could you help me please? Where is the problem? What is best solution for this. Thank you very much.
S.