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!

4 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

  4. on 17 Nov 2019 at 8:11 pm Ronald Chitrik

    Yo, wonderful information. We’re encouraged by your blog posts here. Maybe in the future i’ll be building quality blogs just like this. Love this.!!

Did I get this wrong? Let me know!

Trackback URI | Comments RSS

More blogs about http://desk.stinkpot.org:8080/tricks.