The -name
parameter does allow fnmatch style globing patterns, which is not a regular expression and has no negative patterns. So you need one of two alternatives (if you want to filter inside the find operation):
You have the option to use a RE instead. You need to be aware that regular expressions match against the whole path not the name only, so something like this should work:
find ./src -regex '.*/[^_/][^/]*\.php'
An alternative is to combine -name
with a negation expression (-a -not
means „and not“):
find ./src -name '*.php' -a -not -name '_*'