help-bash
[Top][All Lists]
Advanced

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

[Help-bash] taking the name of a variable from another variable


From: Robert Durkacz
Subject: [Help-bash] taking the name of a variable from another variable
Date: Tue, 3 Jul 2018 22:09:24 +1000

How could I write a shell script that takes two arguments, the first to be
interpreted as the name of an environment variable and the second to be the
value of that variable? All the script should do is create an environment
variable with that value.

Whatever I try, I cannot get the shell to evaluate some expression and use
the result as a variable name. Thus for instance
   varvar=var
   $varvar=val
results in
   var=val: command not found

In other words, can I obtain the name of a name of a variable from another
variable?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]