当前位置: 技术问答>linux和unix
linux:这个很简单的shell为什么执行不对?
来源: 互联网 发布时间:2016-02-08
本文导语: #!/bin/bash echo "The bash name and parameter are:" echo " $0 $1 " echo " press y ,or press n " if [ "$1"="y" ] then echo ": yes,i'm sure you input y" elif [ "$1"="n" ] then echo ":your input are n" else echo "none"...
#!/bin/bash
echo "The bash name and parameter are:"
echo " $0 $1 "
echo " press y ,or press n "
if [ "$1"="y" ]
then
echo ": yes,i'm sure you input y"
elif [ "$1"="n" ]
then
echo ":your input are n"
else
echo "none";
fi
~
死活只执行 echo ": yes,i'm sure you input y"这句!
这个shell的语法太诡异了。
echo "The bash name and parameter are:"
echo " $0 $1 "
echo " press y ,or press n "
if [ "$1"="y" ]
then
echo ": yes,i'm sure you input y"
elif [ "$1"="n" ]
then
echo ":your input are n"
else
echo "none";
fi
~
死活只执行 echo ": yes,i'm sure you input y"这句!
这个shell的语法太诡异了。
|
因为你的格式错了
if [ "$1"="y" ]
改成
if [ "$1" = "y" ]
中间要有空格
if [ "$1"="y" ]
改成
if [ "$1" = "y" ]
中间要有空格
|
都被你抡走了@@@