I cannot get composite patterns as described in http://www.gnu.org/software/bash/manual/bashref.html#Pattern-Matching to match inside my case statement:
i=33; case $i in *([A-Za-z0-9]) ) echo "alphanumeric";; * ) echo "bah";; esac;
I would expect the above script to display “alphanumeric” but instead it fails with:
bash: syntax error near unexpected token `('
Any idea what is wrong ?
Try turning on the
extglobshell option like this:Then you can use the extended pattern matching operators:
From the man page: