jeudi 22 septembre 2016

BASH Check if variable match (or not) regexpr

I need a help to find out how to check if a variable matches a defined regexp. Let's say I have the VAR1="Abcd,1234" and all vars have to match the regexpr bellow. As we see, my var does not match as it has a comma, so how to check? I have created the if statement below, but did not work: IF [[ ${VAR1} == ^[a-zA-Z0-9`~!@#$%^&()_+-={}|[]:";'?] ]]* Thanks.

Aucun commentaire:

Enregistrer un commentaire