[ale] BASHing my head

Jim Kinney jim.kinney at gmail.com
Wed Aug 26 17:38:06 EDT 2015


Yeah. What he said.
>From my F22 bash-land (4.3.39):
touch a.pdf A.pdf b.pdf B.pdf c.pdf C.pdf z.pdf Z.pdf
[jkinney at dhcp061167 tmp]$ ls
a.pdf  A.pdf  b.pdf  B.pdf  c.pdf  C.pdf  z.pdf  Z.pdf
[jkinney at dhcp061167 tmp]$ ls | grep "[A-Z].pdf"
A.pdf
B.pdf
C.pdf
Z.pdf
[jkinney at dhcp061167 tmp]$ ls | grep "[a-z].pdf"
a.pdf
b.pdf
c.pdf
z.pdf
On Wed, 2015-08-26 at 15:41 -0400, Ed Cashin wrote:
> I've been biting my tongue here.  I don't think these characteristics
> of bash are congruent with UNIX philosophy.  The people who made UNIX
> complain about bash being bloated.  These characteristics of bash are
> congruent with POSIX philosophy.
> 
> A UNIX-ish way of doing this would be ...
> 
>   ls | grep '^[A-Z].*\.pdf'
> 
> 
> On Wed, Aug 26, 2015 at 1:41 PM, Jim Kinney <jim.kinney at gmail.com>
> wrote:
> > Wow! Shopt has enough options to make it stand next to emacs.
> > I don't understand why the default is essentially case insensitive
> > when everything else in bash is case sensitive. It looks like the
> > LANG makes it work that way but that makes no sense either to me. A
> > != a in standard US English.
> > More of the secret mysteries of Unix philosophy I've never wrapped
> > my head around.
> > On Aug 26, 2015 12:16 PM, "Scott Plante" <splante at insightsys.com>
> > wrote:
> > > I didn't know the globasciiranges option.
> > > 
> > > Another solution is the LC_COLLATE variable:
> > > 
> > > splante:/tmp/x/> ls
> > > a.pdf A.pdf b.pdf B.pdf
> > > splante:/tmp/x/> ls [A-Z].pdf
> > > A.pdf b.pdf B.pdf
> > > splante:/tmp/x/> LC_COLLATE=C
> > > splante:/tmp/x/> ls [A-Z].pdf
> > > A.pdf B.pdf
> > > splante:/tmp/x/> LC_COLLATE=en_US
> > > splante:/tmp/x/> ls [A-Z].pdf
> > > A.pdf b.pdf B.pdf
> > > 
> > > This is probably a better solution:
> > > 
> > > splante:/tmp/x/> ls [[:upper:]].pdf
> > > A.pdf B.pdf
> > > 
> > > 
> > > Scott
> > > 
> > > 
> > > ----- Original Message -----
> > > 
> > > From: "Alex Carver" <agcarver+ale at acarver.net>
> > > To: ale at ale.org
> > > Sent: Wednesday, August 26, 2015 11:34:02 AM
> > > Subject: Re: [ale] BASHing my head
> > > 
> > > You need to set the shopt globasciiranges otherwise it uses the
> > > values
> > > as lexical rather than pure ASCII values.
> > > 
> > > 
> > > On 2015-08-26 08:22, Scott M. Jones wrote:
> > > > For some reason my wildcard search in bash starting with
> > > uppercase
> > > > letters is finding files starting with lower case. I checked my
> > > 'shopt'
> > > > options and they should be correct, but changing them doesn't
> > > change the
> > > > results. In this case I DO want a case sensitive search but I'm
> > > not
> > > > getting that. What am I doing wrong? (Fedora 21 bash BTW.)
> > > >
> > > > [scott at vbox21 tentcards]$ echo $SHELL
> > > > /bin/bash
> > > > [scott at vbox21 tentcards]$ ls [A-Z]*.pdf
> > > > no_materials.pdf tentcard.pdf tentcard_short.pdf tents.pdf
> > > > tents_short.pdf
> > > > [scott at vbox21 tentcards]$ shopt | grep -i case
> > > > nocaseglob off
> > > > nocasematch off
> > > > [scott at vbox21 tentcards]$ shopt -s nocaseglob
> > > > [scott at vbox21 tentcards]$ shopt -s nocasematch
> > > > [scott at vbox21 tentcards]$ ls [A-Z]*.pdf
> > > > no_materials.pdf tentcard.pdf tentcard_short.pdf tents.pdf
> > > > tents_short.pdf
> > > > [scott at vbox21 tentcards]$ shopt | grep -i case
> > > > nocaseglob on
> > > > nocasematch on
> > > > [scott at vbox21 tentcards]$
> > > > _______________________________________________
> > > > Ale mailing list
> > > > Ale at ale.org
> > > > http://mail.ale.org/mailman/listinfo/ale
> > > > See JOBS, ANNOUNCE and SCHOOLS lists at
> > > > http://mail.ale.org/mailman/listinfo
> > > >
> > > 
> > > _______________________________________________
> > > Ale mailing list
> > > Ale at ale.org
> > > http://mail.ale.org/mailman/listinfo/ale
> > > See JOBS, ANNOUNCE and SCHOOLS lists at
> > > http://mail.ale.org/mailman/listinfo
> > > _______________________________________________
> > > Ale mailing list
> > > Ale at ale.org
> > > http://mail.ale.org/mailman/listinfo/ale
> > > See JOBS, ANNOUNCE and SCHOOLS lists at
> > > http://mail.ale.org/mailman/listinfo
> > > 
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
> > http://mail.ale.org/mailman/listinfo/ale
> > See JOBS, ANNOUNCE and SCHOOLS lists at
> > http://mail.ale.org/mailman/listinfo
> > 
> 
> 
> -- 
>   Ed Cashin <ecashin at noserose.net>
-- 
James P. Kinney III

Every time you stop a school, you will have to build a jail. What you
gain at one end you lose at the other. It's like feeding a dog on his
own tail. It won't fatten the dog.
- Speech 11/23/1900 Mark Twain

http://heretothereideas.blogspot.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20150826/bf1c79c2/attachment.html>


More information about the Ale mailing list