I’m looking to match a file extension pattern in a Bash case statement.
So far I have tried /(\.).{3}/:
case ${myArray[count]} in
*CODE*) $codeFound[count]=${myArray[count]};;
/(\.).{3}/) $extensionFound[count]=${myArray[count]};;
esac
The pattern match for CODE works, however I am having trouble with the pattern for file extensions.
The above throws an error:
syntax error near unexpected token `(‘
If I wrap the RegEx in @() e.g. @(/(\.).{3}/) the pattern isn’t matched either.
Thanks
The pattern matching in a case statement does not use regular expression. From the manpage:
You will either need to use a block of if statements, or do further regex checking based on a loose glob in the case statement.