Feed on

turns out floating point division (or any other type of floating point math) isn’t built-into the bash shell.  instead, you’ll have to use the bc utility:

echo “6.0/10″ | bc -l

Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

3 Responses to “perform floating point calculations in bash”

  1. on 07 Jun 2007 at 4:47 pm Forrest

    echo ’4*a(1)’ | bc -l

  2. on 10 May 2011 at 5:17 am mcb

    Thanks, it is working

    $ echo ’4*a(1)’ | bc -l

  3. on 25 Nov 2011 at 7:30 am Vinod

    Thanks you so much. Was delighted after seeing this.

    Thanks you Jesus

Did I get this wrong? Let me know!

Trackback URI | Comments RSS