shell脚本 比较三个数大小

2024-12-01 09:44:39
推荐回答(1个)
回答1:

输入三个数,从小到大输出:

echo -n "Enter three number:"
read a b c
if [ $a -gt $b ];then
t=$a;a=$b;b=$t;
fi

if [ $a -gt $c ];then
t=$a;a=$c;c=$t;
fi

if [ $b -gt $c ];then
t=$b;b=$c;c=$t;
fi

echo "From small to big:$a,$b,$c"