#!/bin/bash
read -p "input a number:" num
expr $num + 1 &> /dev/null
if [ $? -eq 0 ];then
if [ `expr $num \> 0` -eq 1 ];then
echo "positive"
for((i=1;i<=$num;i++))
do
sum=`expr $sum + $i`
done
echo "sum:$sum"
else
echo "negetive"
fi
fi
bash中的数学运算
最新推荐文章于 2022-05-22 11:39:42 发布