Feed on
Posts
Comments

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

Stumble it!

if that was helpful ...

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

One Response to “perform floating point calculations in bash”

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

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

Did I get this wrong? Let me know!

Trackback URI | Comments RSS

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