5 ms·
On many systems, grep '[A-Z]' will match 'y' but not 'z' (note the case). This is due to collation of the system's locale, which intersperses upper- and
by colanderman 6y ago
On many systems,
grep '[A-Z]'
will match 'y' but not 'z' (note the case). This is due to collation of the system's locale, which intersperses upper- and lowercase letters.
Usually what you want instead is
LC_ALL=C grep '[A-Z]'
(to match ASCII uppercase letters), or
grep '[[:upper:]]'
(to match your locale's uppercase letters).
FWIW I cannot reproduce this on my system any longer; it seems to vary by distribution. See e.g. [1].
[1] https://unix.stackexchange.com/questions/15980/does-should-lc-collate-affect-character-ranges#comment171877_16066 https://unix.stackexchange.com/questions/15980/does-should-l...