首页 > 系统服务 > 详细

编写一个shell,输入任意三个整数,判断最大数。

时间:2021-04-28 19:09:21      阅读:24      评论:0      收藏:0      [点我收藏+]
 1 #!/bin/bash
 2 echo "Enter 3 numbers,please"
 3 read -r -p "input the first number: " n1
 4 read -r -p "input the second number: " n2
 5 read -r -p "input the third number: " n3
 6 MAX=$n1
 7 if [ "$n2" -ge "$n1" ]; then
 8     MAX=$n2
 9 fi
10 if [ "$n3" -ge "$MAX" ]; then
11     MAX=$n3
12 fi
13 echo "The max number is $MAX"

比较简单,注意 [ 两边加 空格。

命令 read  -r    意思是  do not allow backslashes "\" to escape any characters.

 

参照原文:https://blog.csdn.net/muyanmoyang/article/details/48136945

 

编写一个shell,输入任意三个整数,判断最大数。

原文:https://www.cnblogs.com/tm2002/p/14714842.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!