[ale] BASHing my head

Jim Kinney jkinney at jimkinney.us
Thu Aug 27 17:35:59 EDT 2015


Sweet. I've been hacking workarounds for years for all of those "Bad!"
scenarios still using ls :-)
I had never considered creating a file with a newline in the *&$% name!
What a PItA!
New stuff to consider for next pile of crap I write.
On Thu, 2015-08-27 at 16:01 -0400, Scott Plante wrote:
> This link gives some examples of the trouble you can find when you
> parse ls:
> 
> http://mywiki.wooledge.org/ParsingLs
> 
> It doesn't mention it, but another good rule might be NEVER put
> newlines in your filenames!
> 
> 
> From: "Jim Kinney" <jkinney at jimkinney.us>
> To: "Atlanta Linux Enthusiasts" <ale at ale.org>, "DJ-Pfulio" <
> DJPfulio at jdpfu.com>
> Sent: Thursday, August 27, 2015 6:56:46 AM
> Subject: Re: [ale] BASHing my head
> 
> I've not heard that but ls output can be a challenge. Parsing ls -A1
> is fun.
> 
> On August 26, 2015 6:23:06 PM EDT, DJ-Pfulio <DJPfulio at jdpfu.com>
> wrote:
> > I seem to recall being told to NEVER parse the output from ls -
> > ever.
> > Maybe I misunderstood?
> > 
> > On 08/26/2015 05:38 PM, Jim Kinney wrote:
> > >  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 congrue
> > > >  nt 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:
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20150827/3f06e34f/attachment.html>


More information about the Ale mailing list