刚学习shell,有一个脚本,执行时总出错:unexpected operator.
发表于 : 2009-08-21 12:01
系统版本是ubuntu 9.04 desktop.跟着学习鸟哥的私房菜到了shell script那一节,
脚本如下:
#!/bin/bash
# Program:
# This program shows the user's choice
# History:
# 2005/08/25 VBird First release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
read -p "Please input (Y/N): " yn
[ "$yn" == "Y" -o "$yn" == "y" ] && echo "OK, continue" && exit 0
[ "$yn" == "N" -o "$yn" == "n" ] && echo "Oh, interrupt!" && exit 0
echo "I don't know what your choice is" && exit 0
执行时总提示错误
root@dustsnow-laptop:~/scripts# sh sh06.sh
Please input (Y/N): y
[: 10: y: unexpected operator
[: 11: y: unexpected operator
I don't know what your choice is
但是在虚拟机的fedora 11系统中却执行正确.
在网上也查找不到解决方法.
有遇到相同问题的么,
先谢过了
脚本如下:
#!/bin/bash
# Program:
# This program shows the user's choice
# History:
# 2005/08/25 VBird First release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
read -p "Please input (Y/N): " yn
[ "$yn" == "Y" -o "$yn" == "y" ] && echo "OK, continue" && exit 0
[ "$yn" == "N" -o "$yn" == "n" ] && echo "Oh, interrupt!" && exit 0
echo "I don't know what your choice is" && exit 0
执行时总提示错误
root@dustsnow-laptop:~/scripts# sh sh06.sh
Please input (Y/N): y
[: 10: y: unexpected operator
[: 11: y: unexpected operator
I don't know what your choice is
但是在虚拟机的fedora 11系统中却执行正确.
在网上也查找不到解决方法.
有遇到相同问题的么,
先谢过了