Subject: Re: bug#18446: A bracket expression with \- not work. grep v 2.14

From: Paul Eggert <[email-masked]>
Date: Wed, 10 Sep 2014 14:05:22 -0700

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]'