[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] If there a neat way of peeling apart bash variable by delimters?
- Subject: [ale] If there a neat way of peeling apart bash variable by delimters?
- From: neal at mnopltd.com (Neal Rhodes)
- Date: Sun, 14 Sep 2014 19:41:20 -0400
If in a shell script, you have a variable loaded with a character value,
and there is a delimiter, and you want to peel it apart by that
delimiter, is there a built-in expression to do that?
Here's what I'm doing, and I'm thinking there should be a better way.
FULLNAME=$1 #eg:
CustomerEntry.CreditLimit
DOT=`expr index $FULLNAME .`
DOTM1=`expr $DOT - 1`
TABLE=${FULLNAME:0:$DOTM1}
FIELD=${FULLNAME:$DOT:40}
Neal Rhodes
President, MNOP Ltd
Lilburn, GA
770-972-5430
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20140914/3c89902c/attachment.html>