On 09/10/2014 08:23 AM, nezhevenko wrote:
echo 'd' | grep -E '[A\-Z]'
d

grep is working correctly here, I'm afraid. Backslash is not special there, so '[A\-Z]' matches 'A' and all characters in the range from '\' through 'Z'. The size of the range depends on the locale; in some locales the range is invalid (because '\' sorts after 'Z') but in some it's valid and may include 'd', which is what evidently happened for you.

To get the behavior you want, use the pattern '[-AZ]'



Reply via email to