As @Renich suggests (but with an important typo that has not been fixed unfortunately), you can also use extended globbing for pattern matching. So you can use the same patterns you use to match files in command arguments (e.g. ls *.pdf
) inside of bash comparisons.
For your particular case you can do the following.
if [[ "${cms}" != @(wordpress|magento|typo3) ]]
The @
means "Matches one of the given patterns". So this is basically saying cms
is not equal to 'wordpress' OR 'magento' OR 'typo3'. In normal regular expression syntax @ is similar to just ^(wordpress|magento|typo3)$
.
Mitch Frazier has two good articles in the Linux Journal on this Pattern Matching In Bash and Bash Extended Globbing.
For more background on extended globbing see Pattern Matching (Bash Reference Manual).