Arithmetic in Linux Shell (Linux Shell中的数学运算)

The caculation of Integer:

  1. let

i=3;
j=5;
let sum=i+j;
let sum++;
echo $sum;

 

  2. $(())

sum=$((i+j));

 

  3. $[]

sum=$[i+j];

 

  4. expr

sum1=`expr i+j`
sum2=$(expr $i+10)

 

 

The caculation of Float:
  1. bc  

result=`echo "scale=2; 2/3" | bc`;
echo $result;

 

  

posted on 2013-02-17 11:22  name2579  阅读(570)  评论(0编辑  收藏  举报

导航