0

I have a very simple example of searching for a whole word in bash:

TEST="red green blue"
if [[ $TEST =~ red\b ]]; then echo "true"; fi

This works fine in bash --version:

3.2.25(1)-release (x86_64-redhat-linux-gnu)

But a newer server does not return true.

The bash version of the newer server is:

4.1.2(1)-release (x86_64-redhat-linux-gnu)

If I remove the \b it returns true.

But in my case I need the \b to search for wordbreak, as I do not want it to return if a word is redden for example. Any ideas?

Cyrus
  • 84,225
  • 14
  • 89
  • 153
gmate2008
  • 11
  • 1

0 Answers0