<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.28.3">
</HEAD>
<BODY>
Yes, I remember the IFS=, and the OIFS=$IFS, and then IFS=, and then put it back, but was trying to not disturb the argument list by doing a set statement, and it just reads so terribly.&nbsp;&nbsp; <BR>
<BR>
Thanks. <BR>
<BR>
On Mon, 2014-09-15 at 08:18 -0400, Ed Cashin wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Yes, Mike's right that you asked for a bash way and he gave you one.

If, though, you decide you would rather maintain compatibility with
minimal POSIX shells that don't have full bash support, you can use
the old-school Bourne shell features, $IFS and &quot;set&quot;.  I think IFS
stands for &quot;internal field separator.&quot;

Just set the field separator to your field separator.  After calling
&quot;set&quot; with the string to peel apart, the numbered variables will
correspond to the peeled-apart fields.

In the transcript below I'm checking that it works in the Korn shell
after verifying it in bash beforehand.

  bash$ PS1='ksh$ ' ksh
  ksh$ name=First.Last
  ksh$ IFS=.
  ksh$ set $name
  ksh$ echo $1
  First
  ksh$ echo $2
  Last
  ksh$ ^D
  bash$




On Sun, Sep 14, 2014 at 9:38 PM, Michael H. Warfield &lt;<A HREF="mailto:mhw@wittsend.com">mhw@wittsend.com</A>&gt; wrote:
&gt; On Sun, 2014-09-14 at 19:41 -0400, Neal Rhodes wrote:
&gt;&gt; If in a shell script, you have a variable loaded with a character value,
&gt;&gt; and there is a delimiter, and you want to peel it apart by that
&gt;&gt; delimiter, is there a built-in expression to do that?
&gt;
&gt;&gt; Here's what I'm doing, and I'm thinking there should be a better way.
&gt;
&gt;&gt;         FULLNAME=$1                                  #eg:
&gt;&gt; CustomerEntry.CreditLimit
&gt;&gt;         DOT=`expr index $FULLNAME .`
&gt;&gt;         DOTM1=`expr $DOT - 1`
&gt;&gt;         TABLE=${FULLNAME:0:$DOTM1}
&gt;&gt;         FIELD=${FULLNAME:$DOT:40}
&gt;
&gt; Yes there is.  You specifically said &quot;bash&quot; in the subject and in the
&gt; talks we've had a ALE and AUUG over &quot;belts and suspenders bash&quot; the
&gt; speaker mentioned using regex's in bash and accessing the underlying
&gt; substring results.  Look for BASH_REMATCH variables and the =~ operator
&gt; in the bash documentation.
&gt;
&gt; --
&gt; FOO=CustomerEntry.CreditLimit
&gt;
&gt; if [[ &quot;${FOO}&quot; =~ (.*)\.(.*) ]] ; then
&gt;         echo &quot;${BASH_REMATCH[1]} : ${BASH_REMATCH[2]}&quot;
&gt; else
&gt;         echo nope
&gt; fi
&gt;
&gt; CustomerEntry : CreditLimit
&gt; --
&gt;
&gt; Is that what you're after?
&gt;
&gt;&gt; Neal Rhodes
&gt;&gt; President, MNOP Ltd
&gt;&gt; Lilburn, GA
&gt;&gt; 770-972-5430
&gt;&gt; -------------- next part --------------
&gt;&gt; An HTML attachment was scrubbed...
&gt;&gt; URL: &lt;<A HREF="http://mail.ale.org/pipermail/ale/attachments/20140914/3c89902c/attachment.html">http://mail.ale.org/pipermail/ale/attachments/20140914/3c89902c/attachment.html</A>&gt;
&gt;
&gt; Regards,
&gt; Mike
&gt; --
&gt; Michael H. Warfield (AI4NB) | (770) 978-7061 |  <A HREF="mailto:mhw@WittsEnd.com">mhw@WittsEnd.com</A>
&gt;    /\/\|=mhw=|\/\/          | (678) 463-0932 |  <A HREF="http://www.wittsend.com/mhw/">http://www.wittsend.com/mhw/</A>
&gt;    NIC whois: MHW9          | An optimist believes we live in the best of all
&gt;  PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!
&gt;
&gt; -------------- next part --------------
&gt; A non-text attachment was scrubbed...
&gt; Name: signature.asc
&gt; Type: application/pgp-signature
&gt; Size: 465 bytes
&gt; Desc: This is a digitally signed message part
&gt; URL: &lt;<A HREF="http://mail.ale.org/pipermail/ale/attachments/20140914/e2365bf0/attachment.sig">http://mail.ale.org/pipermail/ale/attachments/20140914/e2365bf0/attachment.sig</A>&gt;
&gt; _______________________________________________
&gt; Ale mailing list
&gt; <A HREF="mailto:Ale@ale.org">Ale@ale.org</A>
&gt; <A HREF="http://mail.ale.org/mailman/listinfo/ale">http://mail.ale.org/mailman/listinfo/ale</A>
&gt; See JOBS, ANNOUNCE and SCHOOLS lists at
&gt; <A HREF="http://mail.ale.org/mailman/listinfo">http://mail.ale.org/mailman/listinfo</A>



</PRE>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>