Bash Multiplying Decimal to int Bash Multiplying Decimal to int bash bash

Bash Multiplying Decimal to int


this works:

PRICE=1.1QTY=21RES=$(echo "scale=4; $PRICE*$QTY" | bc)echo $RES


var=$(echo "scale=2;$PRICE*$QTY" |bc)

You can also use awk

awk -vp=$PRICE -vq=$QTY 'BEGIN{printf "%.2f" ,p * q}'


T="$(echo "$PRICE*$QTY" | bc)"