当前位置: 技术问答>linux和unix
新手的BASH代码错误,求帮忙解决
来源: 互联网 发布时间:2016-12-08
本文导语: #!/bin/bash declare rain="1" while ["$rain" -eq "1"] do clear echo "" echo "is it rain?" echo "" echo "1.Yes" echo "2.No" ...
#!/bin/bash
declare rain="1"
while ["$rain" -eq "1"]
do
clear
echo ""
echo "is it rain?"
echo ""
echo "1.Yes"
echo "2.No"
echo ""
echo "Enter your selection:"
read rain
done
echo "It stopped raining."
为啥运行时一直提示
luo@luo-Aspire-4730Z:~$ chmod 711 f
luo@luo-Aspire-4730Z:~$ ./f
./f: line 3: [1:找不到命令
It stopped raining.
luo@luo-Aspire-4730Z:~$
求解决啊
declare rain="1"
while ["$rain" -eq "1"]
do
clear
echo ""
echo "is it rain?"
echo ""
echo "1.Yes"
echo "2.No"
echo ""
echo "Enter your selection:"
read rain
done
echo "It stopped raining."
为啥运行时一直提示
luo@luo-Aspire-4730Z:~$ chmod 711 f
luo@luo-Aspire-4730Z:~$ ./f
./f: line 3: [1:找不到命令
It stopped raining.
luo@luo-Aspire-4730Z:~$
求解决啊
|
while [ "$rain" -eq "1" ]
注意空格,还有应该用=
注意空格,还有应该用=