用户输入3个整数,脚本根据数字大小依次升序输出3个数字
#!/bin/bash
echo "Please enter three integers:"
read -r num1 num2 num3
echo "Sorted integers in ascending order:"
echo "$num1 $num2 $num3" | tr ' ' '\n' | sort -n | tr '\n' '\n'
运行结果:
用户输入3个整数,脚本根据数字大小依次升序输出3个数字
#!/bin/bash
echo "Please enter three integers:"
read -r num1 num2 num3
echo "Sorted integers in ascending order:"
echo "$num1 $num2 $num3" | tr ' ' '\n' | sort -n | tr '\n' '\n'
运行结果: