2

This question already has an answer here:

Ran across a shell script that had '=~' in a contitional and I was wondering what it meant. Not much luck on Google or SO sites.

Example:

if [[ $VAR =~ 'this string' ]]

marked as duplicate by Community Sep 24 '15 at 16:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @EvgenyVereshchagin That would have worked. If only I had worded my question a little differently it would have probably showed up. – sareed Sep 24 '15 at 16:38
7

It's a regular expression match operator.

From the bash man page:

An additional binary operator, =~, is available, with the same
precedence as == and !=.  When it is used, the string to the
right of the operator is considered an extended regular
expression and matched accordingly (as in regex(3)).  The return
value is 0 if the string matches the pattern, and 1 otherwise.

See bash's man page for more details (search for =~)

Not the answer you're looking for? Browse other questions tagged or ask your own question.