vendredi 5 mars 2021

Regex not equal operator?

I'm trying to return a function if the NAMESPACE variable is blank or if the VERSION variable doesn't match the correct pattern.

# return usage if namespace is blank or version doesn't match the version format.
if [[ "$NAMESPACE" == "" || "$VERSION" =~ ^([0-9]\.([1-9]|[1-9][0-9])\.[0-9])$ ]];
    then
        usage
fi

Currently I'm using =~ which returns true if the pattern is x.xx.x or x.x.x. But I'm having trouble finding what the operator would be for not equal (something similar to !=~)

Aucun commentaire:

Enregistrer un commentaire