[ale] If there a neat way of peeling apart bash variable by delimters?

JD jdp at algoloma.com
Sun Sep 14 21:23:28 EDT 2014


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}              
> 


More information about the Ale mailing list