The Not Equal Tilde in bash

Armageddon picture Armageddon · May 26, 2014 · Viewed 10.4k times · Source

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.

Answer

DevSolar picture DevSolar · May 26, 2014

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 ;-) ).