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
?
LC_ALL=C find ...
? – mikeserv Oct 25 '14 at 15:12\/
)? Also what find are you using (find --version
)? – Cristian Ciupitu Oct 25 '14 at 16:16b-d
would match againstch
. Languages may also vary whether they consider lowercase below uppercase or the reverse. This can have some surprising results: [a-Z] may not match anything if Z < a in that locale!". By the way, what does thelocale
command say? – Cristian Ciupitu Oct 25 '14 at 17:07locale
showsen_US.UTF-8
for everything. – Karl Bielefeldt Oct 25 '14 at 17:26/
is only necessary when you're using it as a delimiter, e.g. ins/foo\/bar/foobar/
. (But often you can use some other delimiter:s#foo/bar#foobar#
.) – deltab Oct 26 '14 at 04:32