I just fell for this in a script (not mine).
It seems that grep, awk, sed accept [aZ] based on your locale (i.e. LANG or LC_CTYPE environment variable). In POSIX, [aZ] not allowed by these tools, but in some other locales (for example, en_gb.utf8) it works and matches [a-zA-Z] .
Yes, I checked, it does not match any of _^[]` .
Given that it took quite a while to debug, I strongly discourage anyone from using [aZ] in a regular expression.
Martin Priestley Oct 17 2018-12-12T00: 00Z
source share