<div dir="ltr"><p dir="ltr">A bash equivalent of perl @array=split (delim, $string); would be ideal.</p><p dir="ltr"><br></p><p>string='my,long,string,of,crap'</p><p>OFS=$IFS</p><p>IFS=',' read -a array <<< "$string<code>"</code></p><p>now extract bits as needed:</p><p>echo "${array[0]}"</p><p>my</p><p>echo "${array[1]}"</p><p>long</p><p>etc.<br></p><p><br></p><p><code></code></p><p><code><br></code></p><p><code><br></code></p><pre style class=""><code><span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""></span><span class=""></span></code>On Sep 15, 2014 9:28 PM, "Neal Rhodes" <<a href="mailto:neal@mnopltd.com" target="_blank">neal@mnopltd.com</a>> wrote:<br type="attribution"></pre><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thanks. That is a smidge more compact. Although it doesn't quite jump<br>
off the page w.r.t. readability.<br>
<br>
I was hoping for something along the lines of Progress:<br>
Table = entry(1, FullName, ".").<br>
<br>
But I shall take a look at BASH_REMATCH.<br>
<br>
On Sun, 2014-09-14 at 21:38 -0400, Michael H. Warfield wrote:<br>
<br>
> On Sun, 2014-09-14 at 19:41 -0400, Neal Rhodes wrote:<br>
> > If in a shell script, you have a variable loaded with a character value,<br>
> > and there is a delimiter, and you want to peel it apart by that<br>
> > delimiter, is there a built-in expression to do that?<br>
><br>
> > Here's what I'm doing, and I'm thinking there should be a better way.<br>
><br>
> > FULLNAME=$1 #eg:<br>
> > CustomerEntry.CreditLimit<br>
> > DOT=`expr index $FULLNAME .`<br>
> > DOTM1=`expr $DOT - 1`<br>
> > TABLE=${FULLNAME:0:$DOTM1}<br>
> > FIELD=${FULLNAME:$DOT:40}<br>
><br>
> Yes there is. You specifically said "bash" in the subject and in the<br>
> talks we've had a ALE and AUUG over "belts and suspenders bash" the<br>
> speaker mentioned using regex's in bash and accessing the underlying<br>
> substring results. Look for BASH_REMATCH variables and the =~ operator<br>
> in the bash documentation.<br>
><br>
> --<br>
> FOO=CustomerEntry.CreditLimit<br>
><br>
> if [[ "${FOO}" =~ (.*)\.(.*) ]] ; then<br>
> echo "${BASH_REMATCH[1]} : ${BASH_REMATCH[2]}"<br>
> else<br>
> echo nope<br>
> fi<br>
><br>
> CustomerEntry : CreditLimit<br>
> --<br>
><br>
> Is that what you're after?<br>
><br>
> > Neal Rhodes<br>
> > President, MNOP Ltd<br>
> > Lilburn, GA<br>
> > <a href="tel:770-972-5430" value="+17709725430" target="_blank">770-972-5430</a><br>
> > -------------- next part --------------<br>
> > An HTML attachment was scrubbed...<br>
> > URL: <<a href="http://mail.ale.org/pipermail/ale/attachments/20140914/3c89902c/attachment.html" target="_blank">http://mail.ale.org/pipermail/ale/attachments/20140914/3c89902c/attachment.html</a>><br>
><br>
> Regards,<br>
> Mike<br>
<br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.ale.org/pipermail/ale/attachments/20140915/8848b893/attachment.html" target="_blank">http://mail.ale.org/pipermail/ale/attachments/20140915/8848b893/attachment.html</a>><br>
_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org" target="_blank">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
</blockquote></div>
</div>