没有执行条件检查,它只是打印echo语句以进行合法输入

时间:2018-09-18 09:03:50

标签: bash if-statement conditional

read a
if [[ $a != 'A' || $a != 'a']] && [[ $a != 'B' || $a != 'b' ]] && [[ $a !='C' || $a != 'c']]; then 
       echo "ABC only"
fi

1 个答案:

答案 0 :(得分:0)

read -rN1 a
if [[ "$a" =~ [^AaBbCc] ]]; then
    echo "ABC only"
fi