mercredi 9 juin 2021

how to use IF to test if a value meets a certain mask

I have a variable and I need to test if it contain a formated value like this ........-....-....-....-............

the variable can contem any value in any format, and I need to test if the value is like 1572C097-4452-4495-8369-C7606F2C867E

I tried using seed to retrieve the value from another variable

tguid=$(echo $i |sed 's/.*\(........-....-....-....-............\).*/\1/')

But now, I dont have a clue how can I use if [] statement to guarantee if the variable tguid have the correct value?

Aucun commentaire:

Enregistrer un commentaire