To do small calculations without starting your calculator utility here is a small trick. Suppose you want to multiply 2 and 3, do this -
$ echo $[2*3]
However if you wanted to divide 2 by 3
$ echo $[2/3]
would give a '0'.
We can still make use of the command line to get the correct answer. We have to use 'bc'. Like this -
$ echo '2 / 3' | bc -l
Here is the output -
.66666666666666666666
Subscribe to:
Post Comments (Atom)


0 comments:
Post a Comment