The first example without pipe return empty.

find /tmp/txz/httperf/httperf-20210403git/ -regextype posix-egrep -regex [A-Z][A-Z]$

The second return what I want, all files with capitalized letters, why the find command return nothing?

find /tmp/txz/httperf/httperf-20210403git/ |egrep [A-Z][A-Z]$ 

I have tried also posix-extended and posix-basic for regex-type, but return empty.

  • 2
    You should always quote the argument to -regex and -name, otherwise the shell might expand them before find sees them.
    – Barmar
    Apr 4, 2021 at 14:45

1 Answer 1


As POSIX find does not specify -regex, I assume GNU find.

Test: -regex expr
Test: -iregex expr
True if the entire file name matches regular expression expr. This is a match on the whole path, not a search. […]

(source, emphasis mine)

You should use -regex '.*[A-Z][A-Z]'. Note the expression is single-quoted to prevent expansion by the shell.

  • or something like -regex '.*/[A-Z]+$', to match .../HEAD, but not .../fooBAR
    – ilkkachu
    Apr 3, 2021 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.