Mixing regular expression and other conditional expression in a bash if statement

Posted by Tassos on Stack Overflow See other posts from Stack Overflow or by Tassos
Published on 2010-03-16T09:17:40Z Indexed on 2010/03/16 11:46 UTC
Read the original article Hit count: 499

Filed under:
|
|

I can't get around this for quite sometime now. As I read along manuals and tutorials I'm getting more confused. I want an if statement with the following logic:

if [ -n $drupal_version ] && [[ "$drupal_version" =~ DRUPAL-[6-9]-[1-9][1-9] ]]; then

but I can't get it to work properly.

When the script is evaluated using the "bash -x ... " script construct, works ok but when is run as a regular script my expression is not evaluated (eventhough the above condition should be met the else part is run).

Could you provide any help?

© Stack Overflow or respective owner

Related posts about bash

Related posts about regex