Dreamforlife
Dreamforlife
2017-07-02 02:46

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

  • path
  • shell

#!/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条回答

为你推荐

换一换