<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000'><font face="arial, helvetica, sans-serif"><span style="font-size: 12pt;">This link gives some examples of the trouble you can find when you parse ls:</span></font><div><font face="arial, helvetica, sans-serif"><br></font><div><font face="arial, helvetica, sans-serif">http://mywiki.wooledge.org/ParsingLs</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">It doesn't mention it, but another good rule might be NEVER put newlines in your filenames!<br></font><br><br><hr id="zwchr" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;"><div style="color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-size: 12pt; font-weight: normal; font-style: normal; text-decoration: none;"><b>From: </b>"Jim Kinney" <jkinney@jimkinney.us><br><b>To: </b>"Atlanta Linux Enthusiasts" <ale@ale.org>, "DJ-Pfulio" <DJPfulio@jdpfu.com><br><b>Sent: </b>Thursday, August 27, 2015 6:56:46 AM<br><b>Subject: </b>Re: [ale] BASHing my head<br><br>I've not heard that but ls output can be a challenge. Parsing ls -A1 is fun.<br><br><div class="gmail_quote">On August 26, 2015 6:23:06 PM EDT, DJ-Pfulio <DJPfulio@jdpfu.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">I seem to recall being told to NEVER parse the output from ls - ever.<br>Maybe I misunderstood?<br><br>On 08/26/2015 05:38 PM, Jim Kinney wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> Yeah. What he said.<br> From my F22 bash-land (4.3.39):<br> touch a.pdf A.pdf b.pdf B.pdf c.pdf C.pdf z.pdf Z.pdf<br> [jkinney@dhcp061167 tmp]$ ls<br> a.pdf A.pdf b.pdf B.pdf c.pdf C.pdf z.pdf Z.pdf<br> [jkinney@dhcp061167 tmp]$ ls | grep "[A-Z].pdf"<br> A.pdf<br> B.pdf<br> C.pdf<br> Z.pdf<br> [jkinney@dhcp061167 tmp]$ ls | grep "[a-z].pdf"<br> a.pdf<br> b.pdf<br> c.pdf<br> z.pdf<br> On Wed, 2015-08-26 at 15:41 -0400, Ed Cashin wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> I've been biting my tongue here. I don't think these characteristics<br> of bash are congrue
nt with
UNIX philosophy. The people who made UNIX<br> complain about bash being bloated. These characteristics of bash are<br> congruent with POSIX philosophy.<br><br> A UNIX-ish way of doing this would be ...<br><br> ls | grep '^[A-Z].*\.pdf'<br><br><br> On Wed, Aug 26, 2015 at 1:41 PM, Jim Kinney <jim.kinney@gmail.com><br> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #8ae234; padding-left: 1ex;"> Wow! Shopt has enough options to make it stand next to emacs.<br> I don't understand why the default is essentially case insensitive<br> when everything else in bash is case sensitive. It looks like the<br> LANG makes it work that way but that makes no sense either to me. A<br> != a in standard US English.<br> More of the secret mysteries of Unix philosophy I've never wrapped<br> my head around.<br> On Aug 26, 2015 12:16 PM, "Scott Plante" <splante@insightsys.com><br> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #fcaf3e; padding-left: 1ex;"> I didn't know the globasciiranges option.<br><br> Another solution is the LC_COLLATE variable:<br></blockquote></blockquote></blockquote></blockquote><hr></pre></blockquote></div></div><br></div></div></div></body></html>