Float and divide into bash

It is a funny and simply tip under bash.
How to deals with float and division under bash. ‘bc’ is your friend such as :

clucas@jupiter:~$ i=$( echo "scale=3; 1/3" | bc)
clucas@jupiter:~$ echo $i

It must found on the net (where I found), but searchable for me on this stuff for future.

NdR :

clucas@pluton:~$ i=$((1/3))
clucas@pluton:~$ echo $i

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.