shell脚本:
!/bin/bash
eam1(){
read -p "pl input ur num1:" num1
read -p "pl input ur num2:" num2
}

eam1

result1=expr $num1 + 0
result2=expr $num2 + 0

if [[ $result1 != $num1 ]];then
echo "pl re-input num"
eam1
elif [[ $result2 != $num2 ]];then
echo "pl re-input num"
eam1
fi

if [ $num1 -eq $num2 ];then
echo "num1=num2"
elif [ $num1 -gt $num2 ];then
echo "num1>num2"
else
echo "num1<num2"
fi

注意:
elif [[ $result2 != $num2 ]] 这个地方必须用两个 [ ,因为,代码中判断,如果输入的不是两个整数就需要重新输入,像eq ne gt等等只能比较整数,所以我采用了 !=的方式,但他必须用在双()或者双[]中。