read -p "请输入身高(m为单位): " HIGH
if [[ ! "$HIGH" =~ [1].?[0-9]{,2}$ ]];then
echo "输入错误的身高"
exit 1
fi
read -p "请输入体重(kg为单位): " WEIGHT
if [[ ! "$WEIGHT" =~ [2]{1,3}$ ]];then echo "输入错误的体重"; exit 1; fi
BMI=echo $WEIGHT/$HIGH^2|bc
if [ $BMI -le 18 ] ;then
echo "你太瘦了,多吃点"
elif [ $BMI -lt 24 ] ;then
echo "身材很棒!"
else
echo "你太胖了,注意节食,加强运动"
fi