I'm trying to get trim off trailing decimal zeroes off a floating point number, but no luck so far.
echo "3/2" | bc -l | sed s/0\{1,\}\$//
1.50000000000000000000
I was hoping to get 1.5
but somehow the trailing zeroes are not truncated. If instead of 0\{1,\}
I explicitly write 0 or 000000 etc, it chops off the zeroes as entered, but obviously I need it to be dynamic.
What's wrong with 0\{1,\}
?
scale
parameter inbc
to reduce the number of decimal places. – Magnifico