shell scripts 在ubuntu下运行所产生的问题
发表于 : 2011-08-30 13:15
#!/bin/bash
# program will show 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
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 know what is your choice" && exit 0
以上这个程序能在suse以及redhat 中正常运行,但是在ubuntu中会出错,出错提示是:
Please input (Y/N): y
[: 11: y: unexpected operator
[: 11: y: unexpected operator
[: 15: y: unexpected operator
[: 15: y: unexpected operator
I don't know what is your choice
请高手予以解答!!
还有一个问题是,在ubuntu中的scripts,如果写echo -e “Hello”。运行时显示的却是
“-e Hello” (也就是说把参数-e也显示出来)。求解。
# program will show 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
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 know what is your choice" && exit 0
以上这个程序能在suse以及redhat 中正常运行,但是在ubuntu中会出错,出错提示是:
Please input (Y/N): y
[: 11: y: unexpected operator
[: 11: y: unexpected operator
[: 15: y: unexpected operator
[: 15: y: unexpected operator
I don't know what is your choice
请高手予以解答!!
还有一个问题是,在ubuntu中的scripts,如果写echo -e “Hello”。运行时显示的却是
“-e Hello” (也就是说把参数-e也显示出来)。求解。