linux的类似函数cmp怎么自己实现类似函数
展开全部
#!/bin/sh
fun()
{
sum=0
for i in `seq $1 $2`
do
sum=`expr $i + $sum`
done
echo $sum
}
echo "Please input 2 number:"
read a b
expr $a + 0 1>/dev/null 2>
if [[ $? -ne 0 ]];then
echo "wrong number"
exit 1;
fi
expr $b + 0 1>/dev/null 2>
if [[ $? -ne 0 ]];then
echo "wrong number"
exit 1;
fi
if [[ $a -ge $b ]];then
echo "wrong number"
exit 1;
fi
fun $a $b
fun()
{
sum=0
for i in `seq $1 $2`
do
sum=`expr $i + $sum`
done
echo $sum
}
echo "Please input 2 number:"
read a b
expr $a + 0 1>/dev/null 2>
if [[ $? -ne 0 ]];then
echo "wrong number"
exit 1;
fi
expr $b + 0 1>/dev/null 2>
if [[ $? -ne 0 ]];then
echo "wrong number"
exit 1;
fi
if [[ $a -ge $b ]];then
echo "wrong number"
exit 1;
fi
fun $a $b
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询