[lug] grep question

Chip Atkinson chip at pupman.com
Tue Jun 12 19:26:03 MDT 2007


ha ha!  Yeah, how crazy is this?

chip at chip1:~> echo "a" | grep [A-Z]
chip at chip1:~> echo "b" | grep [A-Z]
b

Which fits your conclusion perfectly.  

On Tue, 12 Jun 2007, Steve Sullivan wrote:

> Interesting.  Here's another test, running on Suse 10.2 professional:
> 
> 
> $ echo $LANG
> en_US.UTF-8
> 
> 
> 
> $ for pat in a b A B ab a-b AB A-B; do
>    for text in a b A B; do
>       echo pat: $pat  text: $text  result: $(echo $text | /usr/bin/grep "[$pat]")
>     done
> done
> 
> pat: a text: a result: a
> pat: a text: b result:
> pat: a text: A result:
> pat: a text: B result:
> pat: b text: a result:
> pat: b text: b result: b
> pat: b text: A result:
> pat: b text: B result:
> pat: A text: a result:
> pat: A text: b result:
> pat: A text: A result: A
> pat: A text: B result:
> pat: B text: a result:
> pat: B text: b result:
> pat: B text: A result:
> pat: B text: B result: B
> pat: ab text: a result: a
> pat: ab text: b result: b
> pat: ab text: A result:
> pat: ab text: B result:
> pat: a-b text: a result: a
> pat: a-b text: b result: b
> pat: a-b text: A result: A
> pat: a-b text: B result:
> pat: AB text: a result:
> pat: AB text: b result:
> pat: AB text: A result: A
> pat: AB text: B result: B
> pat: A-B text: a result:
> pat: A-B text: b result: b
> pat: A-B text: A result: A
> pat: A-B text: B result: B
> 
> It looks like the Suse sort order is: aAbB
> so [A-B] includes b but not a.
> And [a-b] includes A but not B.
> 
> Steve
> 
> 
> On Tue, Jun 12, 2007 at 07:45:16AM -0600, Chip Atkinson wrote:
> > Ok, here's something to chew on:
> > 
> > chip at chip1:~> echo $LANG
> > en_US.UTF-8
> > chip at chip1:~> echo abc | grep A
> > chip at chip1:~> echo abc | grep a
> > abc
> > chip at chip1:~> echo abc | grep "[A-Z]"
> > abc
> > chip at chip1:~> export LANG=C
> > chip at chip1:~> echo abc | grep "[A-Z]"
> > chip at chip1:~> 
> > 
> > The distribution is SuSE enterprise linux.  It seems that the LANG stuff
> > only affects an expression in set of mini-experiments.  
> > 
> > Another thing that is odd is that there are many programs in /usr/bin with
> > symlinks to their counterpart in /bin.  However, /usr/bin isn't a symlink
> > to /bin.  I guess SuSE is "non-standard", but I thought it was a Red Hat
> > derivative.
> > 
> > Chip
> > 
> > On Mon, 11 Jun 2007, Collins Richey wrote:
> > 
> > > On 6/10/07, Jeffrey Haemer <jeffrey.haemer at gmail.com> wrote:
> > > > export LANG=C
> > > >
> > > > will cure this problem.
> > > >
> > > 
> > > OK, read your explanation (LANG=C), but I have LANG=en_US.UTF-8, and I
> > > don't have the problem. I find it hard to believe that any distro
> > > would have a LANG= setting that would include lower case characters in
> > > the range A-Z. Even in unadulterated EBCDIC, abcde, etc. would not be
> > > a subset of A-Z.
> > > 
> > > OTOH, a distro with /usr/bin/grep is already quite non-standard.
> > > 
> > > -- 
> > > Collins Richey
> > >      If you fill your heart with regrets of yesterday and the worries
> > >      of tomorrow, you have no today to be thankful for.
> > > _______________________________________________
> > > Web Page:  http://lug.boulder.co.us
> > > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> > > Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
> > > 
> > 
> > _______________________________________________
> > Web Page:  http://lug.boulder.co.us
> > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> > Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
> 
> -- 
> 
> ========================================
> Steve Sullivan    sullivan at mathcom.com
> 
> http://www.mathcom.com    303-494-7115
> ========================================
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
> 




More information about the LUG mailing list