There are several useful ways to achieve this (in bash
):
two checks
echo -n "Enter test: "
read test
if [[ $test == "a" || $test == "A" ]]; then
echo "worked"
else
echo "failed"
fi
make the input lower case
echo -n "Enter test: "
read test
test="${test,,}"
if [[ $test == "a" ]]; then
echo "worked"
else
echo "failed"
fi
regex for both cases
echo -n "Enter test: "
read test
if [[ $test =~ ^[aA]$ ]]; then
echo "worked"
else
echo "failed"
fi
make the shell ignore the case
echo -n "Enter test: "
read test
shopt -s nocasematch
if [[ $test == a ]]; then
echo "worked"
else
echo "failed"
fi