#!/bin/bash
#######expr 方法是错误的,在比较相同位数时可以,当位数不同就会出错,如100.00>70.00就会得出错误的结果
a=123
b=123
c=99.99
rat=`awk 'BEGIN{printf "%.2f\n",('${a}'/'${b}')*100}'`
echo $rat
if [[ `expr ${rat} \> 70.00` -eq 0 ]];then
echo 0
else
echo 1
fi
if [[ `expr ${c} \> 70.00` -eq 0 ]];then
echo 0
else
echo 1
fi
##################借助linux 计算器bc命令比较,可以得出可依赖的结果
if [[ $(echo "$rat > 70.00"|bc) -eq 1 ]]; then
echo "-------"
else
echo "+++++++"
fi
if [[ $(echo "${c} > 70.00"|bc) -eq 1 ]]; then
echo "-------"
else
echo "+++++++"
fi