How to convert Scientific Notation number to Decimal using bash?


Turns out this is pretty easy to do using awk and printf in bash!

Lets say you have a scientific value of “2.1061863333e+03” and you wish to convert it to decimal. You can do something like below:

>> echo "2.1061863333e+03" | awk {' printf "%12.2fn",$1 '}
     2106.19

  • Obviously you can do the same if you have series of values in a file using cat.
  • I found this specially useful when obtaining values from RRDs.

  1. No comments yet.
(will not be published)
*