如何根据表达式更改布尔变量?

时间:2017-04-02 14:58:33

标签: variables expression sh

我试图在bash脚本(Debian Jessie)中使用表达式更改布尔变量的值,但它没有按预期工作! 这是我的代码

vld=true
while ! [ $vld ]
do
echo "Enter a number: [1-30]:"
read myinput
$vld=[ $myinput -ge 1 ] && [ $myinput -le 30 ]
done
echo "Your number is $myinput

当我在这个剧本中说:

8: ./test.sh true=[: not found

然后它继续循环,因为变量没有接收表达式的结果但是自己使用了!

0 个答案:

没有答案