[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: jdp at algoloma.com (JD)
- Date: Sun, 14 Sep 2014 21:23:28 -0400
- In-reply-to: <[email protected]>
- References: <[email protected]>
http://tldp.org/LDP/abs/html/internalvariables.html
the $IFS is what you want, I think.
On 09/14/2014 07:41 PM, Neal Rhodes wrote:
> 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}
>