Search code examples
bashshellequalstilde

The Not Equal Tilde in bash


Like presented in the title, What's the opposite of "=~" operator? I really googled for that and I fund just the following solution: [[ ! $str1 =~ $str2 ]] Is there any operator that verify the opposite of "=~" operator?

Thanks.


Solution

  • There is no opposing operator in bash up to version 4.3 (current at the time of this post).

    [[ ! str1 =~ str2 ]] is the way to go.

    For such questions, you should use man instead of your favourite search engine. The man page of the tool involved -- bash, in this case -- is authoritative, the 'web is hearsay (unless, of course, it led you to the man page ;-) ).