Problems with enhanced features in -regex of utility "find" For example, this doesn't find the file:

: &gt; 12; basename $(find -E . -regex '^(.*)(\d{2})' -print 2&gt;/dev/null)


But this does:

basename $(find -E . -regex '^(.*)([0-9]{2})' -print 2&gt;/dev/null)


At the same time, for example:

echo -e '12\nabc\n456' | grep -E -e '^(\d{3})'


works quite well, though seemingly uses the same regcomp().

What am I doing wrong and how can I fix it?
It appears there is a bug in the native MacOS find in which its -regex option does not correctly handle any of the Shortcuts described in man re_format. The following command seems to work:

find -E . -regex '^(.*)([[:digit:]]{2})' -print


This slightly simpler variant also seems to work:

find -E . -regex '.*[[:digit:]]{2}' -print


In short, grep -E and finds -regex option don't seem to handle regular expressions in exactly the same way.