qq_28210869
Vivian98756
2017-11-18 01:52

Linux shell script编程

10
  • linux

直接上代码

 #!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

read -p "input (Y|N):" yn

if [ "$yn" == "Y" ] || [ "$yn" == "y" ] ; then
      echo "OK.good " 
        exit 0
fi

if [ "$yn" == "N" ] || [ "$yn" == "n" ] ; then
     echo "no,it's bad "
       exit 0
fi

echo "i don't know what choice on you" && exit 0


#错误信息
#sh06-2.sh: 7: [: n: unexpected operator
#sh06-2.sh: 7: [: n: unexpected operator
#sh06-2.sh: 12: [: n: unexpected operator
#sh06-2.sh: 12: [: n: unexpected operator
#i don't know what choice on you

我输入的是 n

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐