One could use pcregrep
. It comes with the package pcre
in CentOS and pcregrep
in Ubuntu.
grep -P
could have this issue depending on the OS / version:
-P, --perl-regexp
Interpret PATTERN as a Perl regular expression. This is highly experimental and grep -P may warn of unimplemented features.