Display value of environment variable

Display value of environment variable

Post by Clif » Wed, 14 Feb 2001 09:02:27



Hi, I am learing bash shell. I am trying to write a script that will display
the value of the environment variables that passed as arguments. But I don't
know how I can print out their values. The usage is like if you type

showvar.sh UID USER

it should print out
UID=2231
USER=tom

This is what I have. Thanks.


echo "$x = $x"

done

 
 
 

Display value of environment variable

Post by Derek M. Fly » Wed, 14 Feb 2001 09:17:24



> Hi, I am learing bash shell. I am trying to write a script that will display
> the value of the environment variables that passed as arguments. But I don't
> know how I can print out their values. The usage is like if you type

> showvar.sh UID USER

> it should print out
> UID=2231
> USER=tom

> This is what I have. Thanks.


> echo "$x = $x"

  eval echo "$x = \$$x"

- Show quoted text -

Quote:

> done


 
 
 

1. c shell script; Howto use environement variables to build environment variables and take their value

In a script I wish to specify two environment variables like this;

setenv FOO bee
setenv ${FOO}_ROOT /home/bee

This is ok and will set "FOO=bee" and "bee_ROOT=/home/bee".

Now I wan't to build the "bee_ROOT" variable using "FOO" and use the
value in a expression, i.e. something like this;

source ${${FOO}_ROOT}/.cshrc

This will not execute. The error is "Variable syntax". It seems that
the shell cannot figure to evaluate the inner ecpression first and
then the outer. I have tried different combination of forcing
evaluation with '' and assigning to variable first etc, but with
little luck.

Any idea/explanation why this is not possible/what I can do instead?

Cheers,
Gert.

2. Positions in San Jose

3. How to get value of environment variable in variable name?

4. Setting up multi-machine network...

5. netcfg: TclError: no display name and no $display environment variable

6. Connection to The Internet

7. no display name and no $DISPLAY environment variable

8. diamond stealth 2 S220

9. How to change the value of an environment variable in a script.

10. environment variable doesn't keep its value

11. Max. length of Environment Variable Value Field

12. Is there a Null value for DISPLAY variable?

13. value of the variable DISPLAY AIX