GNU bug report logs - #18446
A bracket expression with \- not work. grep v 2.14

Previous Next

Package: grep;

Reported by: nezhevenko <nezhevenko <at> protei.ru>

Date: Wed, 10 Sep 2014 15:45:04 UTC

Severity: normal

Tags: notabug

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 18446 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: nezhevenko <nezhevenko <at> protei.ru>, 18446 <at> debbugs.gnu.org
Subject: Re: bug#18446: A bracket expression with \- not work. grep v 2.14
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]'




This bug report was last modified 10 years and 254 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.