mercredi 26 juin 2019

If statement with a regex in bash not working

Have two if statements matching a filename with the dates of type YYYYMMDD and YYYY-MM-DD and the lease part has filenames that don't contain name. Now the if statements are not working, the code always goes to the else part.

Ex:

If [[ ${data-file} =~ ([12]\d{3}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])) ]]

Someone please help

Aucun commentaire:

Enregistrer un commentaire