Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] Bourne Shell variable assignment question

On 12/15/2011 04:31 PM, Jerry Feldman wrote:
> On 12/15/2011 04:22 PM, Ben Eisenbraun wrote:
>> On Thu, Dec 15, 2011 at 03:57:04PM -0500, Jerry Feldman wrote:
>>> I have not done my homework on this as much as I should.
>>> A coworker needs to set variable names and values input from another
>>> file. Normally, I would source that file, but he specifically wants to
>>> parse the file.
>>> So, in simple terms, he has a file that has something like:
>>> var1=foo
>>> Instead of sourcing he wants to parse the file using readline so he
>> Readline is a library for that command line apps can use for command
>> editing and history. It's not part of the shell, and I don't think it can
>> be used the way you're suggesting.
>> -b
>> --
>> the wages of gin is breath.                                  <anonymous>
> I meant read and not readline.
> The real issue is:
> I have a variable called varname that contains "myvar"
> I want to be able to use the content of varname to name a variable so
> that myvar becomes a variable.
> In the specific case, my coworker is reading something like"
> myvar=foo
> What he wants to do is the equivalent of sourcing this code, but he
> wants to read it from a file.
> #/bin/sh
> ...
> IFS="=" # This is not the correct way, but I'm just using it as an example
> read varname varvalue
> ### In this case varname contains "myvar", and vavalue contains "foo"
> But, what he wants to end up with is a variable called "myvar"
> containing "foo".
> ### What he wants to do does not make sense to me when sourcing the file
> will work just fine.
Just want to simplify.
--- do something to create myvar.
echo $myvar

Jerry Feldman <gaf at>
Boston Linux and Unix
PGP key id:3BC1EB90 
PGP Key fingerprint: 49E2 C52A FC5A A31F 8D66  C0AF 7CEA 30FC 3BC1 EB90

BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!

Boston Linux & Unix /