how to ignore case

Hi All,

The means I use to ignore case, as an example is the following snippet:
It should accept any oof the following y|Y|YES|Yes|n|N|NO|No

echo "Enter Y/N to continue: "
read choice;

The best way to ignore case is to convert the user input to upper case (or lower case - your choice).

Try this:

$ choice="yes"

$ echo ${choice} | tr "[a-z]" "[A-Z]"
YES
$

HTH, :cool:

Regards,

Praveen

typeset -u var # convert to uppercase no matter what the input is

# checks for all possible input combos
echo $var | sed 's/^YES$/valid/
s/^NO$/valid
s/^Y$/valid
s/$N$/valid'

$ if echo 'yes' | egrep -qi '^(yes|y|no|n)$';then echo "correct";fi
correct