欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

判断输入的是yes还是no

程序员文章站 2022-05-02 08:17:04
...

if写法

#!/bin/bash
read -p "please input yes or no: " YON
if [[ "$YON" =~ ^[Yy][Ee][Ss]$ ]];then
    echo "What you type in is: yes"
elif [[ "$YON" =~ ^[Nn][Oo]$ ]];then
    echo "What you type in is: no"
else
    echo "What you type in is: other"
fi