关于shell script 的一个小程序,求大牛告知出错地方

#!/bin/bash

#program:

This program shows user's choices

#History:
#2017/07/02 dream 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
echo "$YN"
[ " $YN " == " Y " ] && echo "OK, continue" && exit 0
[ " $YN " == " N " ] && echo "Oh, interrupt" && exit 0
echo "I do not know what your choice is $YN " && exit 0
~

~
以下是运行结果
sh sh06.sh
Please input (Y/N): Y
Y
sh06.sh: 14: [: Y : unexpected operator
sh06.sh: 15: [: Y : unexpected operator
I do not know what your choice is Y

1个回答

[]旁边需要空格,不然会报错的

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问