Pages

Thursday, April 16, 2015

Integer Division in BASH

Integer Division in BASH

Default Division in BASH is based on Integer Number(s).

In that case "bc" or "expr" command can be used.


1.bc Command

echo "100/2" | bc 

Will give the output as 50

2. expr Command

((j=100))
((j=2))
k=`expr $j / $k`

Will give the output as 50

No comments:

Post a Comment