Path: utzoo!mnetor!uunet!husc6!tut.cis.ohio-state.edu!bloom-beacon!gatech!mcnc!uvaarpa!umd5!brl-adm!adm!kevinc@bearcat.lim.tek.com From: kevinc@bearcat.lim.tek.com (Kevin Cosgrove 627-5212) Newsgroups: comp.unix.wizards Subject: Building Variable Names in Bourne Shell Message-ID: <12565@brl-adm.ARPA> Date: 22 Mar 88 06:31:43 GMT Sender: news@brl-adm.ARPA Lines: 30 Anyone know how to build *accessible* variable names on the fly in Bourne shell? Below is a do nothing script which, I hope, demonstrates what I want to do. #!/bin/sh onestring="A" # set the values of arbitrary strings twostring="B" threestring="C" for string in one two three # loop thru string sets do var="${string}string" # var contains the name of the string # I wish to get access to echo "\$$var = ${var}" # how do I get the contents of the string # "pointed to" by var? echo done Yes, I know there are lots of other shells and/or languages which make the above easy to do, but I'm trying to patch existing scripts, and this would make it much easier to do. Disclaimer: donning fire resistant suit now... __________________________________________________________________________ Kevin Cosgrove Tektronix, Inc. (503)-627-5212 PO Box 500, M/S 47-092 kevinc@bearcat.LIM.TEK.COM Beaverton, OR 97077 __________________________________________________________________________