今天写shell时与遇到的问题
代码如下:
#!/bin/bash
#program:
# this program show you choice
#history:
#2015.7.3 acceler first release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:~/bin
export PATH
read -p "please input (y/n): " yn
if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then
echo "OK,continue!"
exit 0
fi
if [ "$yn" == "N" ] || [ "$yn" == "n" ]; then
echo "Oh,interrupt"
exit 0
fi
echo "i don't konw what your choice is " && exit 0
保存为 1.sh
运行时输入:bash 1.sh 运行无误
运行时输入:sh 1.sh 出错错误如下:
1.sh: 10: [: y: unexpected operator
1.sh: 10: [: y: unexpected operator
1.sh: 14: [: y: unexpected operator
1.sh: 14: [: y: unexpected operator
i don't konw what your choice is
为什么会这样?....
bash 和 sh 有什么区别???????
写shell关于bash 和 sh .的问题....14.04LTS
-
- 帖子: 26
- 注册时间: 2015-06-27 10:08
- 系统: ubuntu14.04 LTS
- vickycq
- 帖子: 4507
- 注册时间: 2011-03-20 13:12
- 系统: Debian
- 来自: 山东省寿光县
- 联系:
Re: 写shell关于bash 和 sh .的问题....14.04LTS
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
欢迎所有 Debian GNU/Linux 用户