I'm running Ubuntu 11.04. I use the terminal to start a bash session, and I want to add an environment variable:
$r@hajt:~$ env THEVAR=/example
But it's not working. It shows all the variables with THEVAR being the last one, but another call to env
does not show THEVAR
anymore- env | grep THEVAR
returns nothing.
Similarly, scripts with export (export THEVAR=/example
) or other variable assignments (THEVAR=/example
) don't add the environment variable.
I know I'm doing something wrong, I know it should be something simple, but I just can't find what.
UPDATE: The real meaning of my question was this one:
(Anyway I'll choose the most voted answer and leave the edited title -that wasn't what I was asking)
env
runs a program in a modified environment, then dismisses all the changes.