[root@ localhost shell]# vim s6.sh #!/bin/bash for i in {1..3} do read -p "请输入第${i}个数:" number${i} done echo "$number1,$number2,$number3" a=0 if [ $number1 -gt $number2 ]; then a=$nuber1 number1=$number2 number2=$a fi if [ $number1 -gt $number3 ]; then a=$nuber1 number1=$number3 number3=$a fi if [ $number2 -gt $number3 ]; then a=$nuber2 number2=$number3 number3=$a fi echo "从小到大输出为:$number1,$number2,$number3"