Bash if-then statements for pattern -
Find some help with if / else statements I have 2 variables for which I want to see an if statement Can I match one pattern within
var1 = "15" var2 = "1 | 2 | 3 | 4 | 5" If [[$ var1 = ~ $ var2]] does not match again
< / Pre>It looks like I try it. I'm feeling that my syntax is wrong. I have to get a 15 or no, a 1 or a 5.
to help [[
:
When the `= ~ 'operator is used, the string corresponds to the right side of the operator as a regular expression.
Your syntax is fine, if something is weird, I will personally use Category [1-5]
.
var2 = "[1-5]"
Comments
Post a Comment