#!/bin/bashwhile true;doread -p "Enter an integer:" numif [ $num -eq 100 ];then breakfidoneexit 0#因为你没说大于,小于后做什么,只说了一个等于100时退出。#那我只能认为不管我输入什么数,还是重复输入,直到我输入100时退出。
[lotto@logging ~]$ cat test.sh#!/bin/shi=0while [ 1 -gt 0 ]doecho -e "请输入数字:"read numif [ $num -gt 100 ]thenecho "大于100"elif [ $num -lt 100 ]thenecho "小于100"elseecho "等于100,退出程序"breakfii=`expr $i 1`done[lotto@logging ~]$ ./test.sh请输入数字:4小于100请输入数字:105大于100请输入数字:100等于100,退出程序[lotto@logging ~]$