1 #!/bin/bash
2
3 read -p "Please interput your choose: " input
4 [[ $input =~ ^([Yy][Ee][Ss]|[Yy])$ ]] && echo "YES"
5 [[ $input =~ ^([Nn][Oo]|[Nn])$ ]] && echo "NO"
#!/bin/bash
read -p "Please interput your choose: " input
case $input in
[Yy][Ee][Ss]|[Yy])
echo "YES"
;;
[Nn][Oo]|[Nn])
echo "NO"
;;
*)
echo "Wrong!"
esac
[03:43:25 root@C8-3-55 ~]#vim yn_1.1.sh
[04:17:58 root@C8-3-55 ~]#bash yn_1.1.sh
Please interput your choose: n
NO
[04:18:07 root@C8-3-55 ~]#bash yn_1.1.sh
Please interput your choose: y
YES
[04:18:11 root@C8-3-55 ~]#bash yn_1.1.sh d
Please interput your choose: d
Wrong!
[04:18:19 root@C8-3-55 ~]#bash yn_1.1.sh
Please interput your choose: f
Wrong!