How do I escape % to make it modulus when piping it to "bc"?
Using the BASH shell, this works:
echo "$RANDOM % 100 " | bc
and this works:
echo "scale=2;$RANDOM*100/7" | bc
but I cannot get SCALE and MODULUS working together no matter what I try. I want random numbers that have one decimal place. What I want is this:
echo "scale=2; $RANDOM%100/10" | bc
or this:
echo "scale=2; ($RANDOM%100)/10" | bc
Posted Dec 1, 2011, 11:38 PM UTC
25