当前位置: 技术问答>linux和unix
If语句中,为什么总是执行不到else下面的程序段
来源: 互联网 发布时间:2015-05-02
本文导语: #!/bin/bash #This program is used to study if then echo "press y to continue: C" read yn echo "you keyin: $yn" if [ "$yn"="y" ] || [ "$yn"="Y" ]; then echo "Script is running..."; else echo "Sorry, you gived the wrong key!"; fi ech...
#!/bin/bash
#This program is used to study if then
echo "press y to continue: C"
read yn
echo "you keyin: $yn"
if [ "$yn"="y" ] || [ "$yn"="Y" ];
then
echo "Script is running...";
else
echo "Sorry, you gived the wrong key!";
fi
echo "Running end!"
请教上面的程序, 为什么总是执行不到else下面的程序段?
#This program is used to study if then
echo "press y to continue: C"
read yn
echo "you keyin: $yn"
if [ "$yn"="y" ] || [ "$yn"="Y" ];
then
echo "Script is running...";
else
echo "Sorry, you gived the wrong key!";
fi
echo "Running end!"
请教上面的程序, 为什么总是执行不到else下面的程序段?
|
if [ "$yn"="y" -o "$yn"="Y" ]
等号两边要有空格。
等号两边要有空格。
|
高手出手果然不一样