Is "2nd level indirection" possible in bash?

Walter Dnes waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org
Thu Aug 30 20:19:40 UTC 2012


On Thu, Aug 30, 2012 at 01:53:17PM -0400, Ben Walton wrote
> Hi Walter,
> 
> > # Routine to assemble date in YYYYMMDD format, using column locations
> > # imported in format file (i.e. 2nd parameter on commandline)
> > calc_yyyymmdd() {
> >    yyyymmdd="${dataline:${f_yr}}${dataline:${f_mo}}${dataline:${f_dy}}"
> >    export yyyymmdd
> > }
> 
> I think this is what you're after (assuming I understand what you're
> trying to do):
> 
> ME=ben
> varname=ME
> echo ${!varname}
> 
> You build up the variable you're after then then use the ! to
> dereference the name.

  Thanks.  That looks like what I want.

-- 
Walter Dnes <waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org>
I don't run "desktop environments"; I run useful applications
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list