Is "2nd level indirection" possible in bash?

Ben Walton bdwalton-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Thu Aug 30 17:53:17 UTC 2012


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
-Ben
-- 
---------------------------------------------------------------------------------------------------------------------------
Ben Walton <bdwalton-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org>

Take the risk of thinking for yourself.  Much more happiness,
truth, beauty and wisdom will come to you that way.

-Christopher Hitchens
---------------------------------------------------------------------------------------------------------------------------
--
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