Find a file where name starts with a capital letter

find

I'm trying to find all files for which there name starts with a capital letter. I have tried using the following command:

find . -type f -regex '.*\/[A-Z][^/]*'

It's finding paths with only lowercase letters. The following works:

find . -type f -regex '.*\/[ABCDEFGHIJKLMNOPQRSTUVWXYZ][^/]*'

As does:

find . -type f | grep '.*\/[A-Z][^/]*$'

I've tried all the different options for regextype, with the same result.

Why does find include lowercase letters in [A-Z]? I thought the regex for that was [a-zA-Z]. Is there any way to specify a range of only uppercase letters in find?

Best Answer

You don't need to use -regex. You can use -name instead.

find . -type f -name "[[:upper:]]*"
Related Question