bash shell env var script
Even though I did this before, I just do not remember what the h?ll I did. Again I am here as a 'newbie'
The script looks like so. ------------------------------- #!/bin/bash export MYVAR=/export/files ------------------------------- What must I do to be sure that MYVAR is available for me after the script completes? |
add MYVAR to your local $PATH
|
Well, that would make sense to me if I wanted MYVAR in the path. Simply, MYVAR is an environment variable that needs to stand on its own. For example, what if I wanted MYVAR=myVALUE.
Thanks in Advance. |
Code:
colabus@xionous:~/mount$ export TEST="hello world" |
Shell vars only affect the current env values.
Using export means they will also take effect in any subsequent shells fired from that shell aka sub-shell. You cannot pass values back up the chain to affect a higher level shell. Use (write to) a file and read it back if you want to do that. eg echo $MYVAR >>file.dat to save, then MYVAR=`cat file.dat` # NB: backquotes, not single quotes to retrieve. |
All times are GMT -5. The time now is 05:43 AM. |