1

I am summing two small decimal numbers contained in two variables:

SEEupper=`expr $SEEmedian+$SEEthre | bc`

but since the result is a number smaller than 1, like 0.XXXX, the output is: '.XXXX'. Is there any way to have an output with the '0' before the dot and the decimals?

Alberto
  • 341
  • 1
  • 3
  • 13

3 Answers3

1

workaround: ... | sed -e "s|^\.|0.|"

Sergey Fedorov
  • 2,169
  • 1
  • 15
  • 26
0

if you can use python:

SEEupper=`python -c "print $SEEmedian +$SEEthre"`
PasteBT
  • 2,128
  • 16
  • 17
0

Yes, with the internal bash command printf:

printf "%g" $SEEupper
thom
  • 2,294
  • 12
  • 9