0

嗨,伙计们,我要解决的问题是,即使您输入 no,while 循环在这两种情况下都可以工作,如果我输入 yes,第二个问题 echo 你想继续,它会在两种情况下都出现

echo would you like to provide  more numbers: 
read des

while [ "$des"=="yes" ];  do

    echo provide a number please:
    read num
    let x=3num+$num
    echo $x

    echo would you like to carry on 
    read new

    if [ "$new"=='no' ]; then
        break
    fi
done
4

2 回答 2

3

要完成字符串比较,请添加空格:

代替

while [ "$des"=="yes" ];  do

while [ "$des" == "yes" ];  do
于 2013-03-06T22:08:02.393 回答
1

尝试这个:

如果 [ "$new" == "否" ]; 然后

于 2013-03-06T21:57:12.400 回答