在while循环中使用continue语句:bash脚本

问题描述

#! /bin/bash 

echo -e "Please enter a number: \c"
read -r x
echo -e "Please enter the last number you wished to have multiplied: \c"
read -r last_num

j=1

while [[ $j -le $last_num ]]
do
    ans=`expr $x \* $j`
    echo "$x * $j = $ans"
    ((j++))
done
echo -e "Do you wish to carry out another multiplication? [y/n] \c"
read -r response

    if [ $response == y -o $response == Y ]; then
    continue
# ***
# the continue statement does not run when I enter Y or y,but the else
# statement do run
# ***
    else
    echo "Goodbye"
    exit
    fi

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)