how to unset environment variable in bash
Hi,
I am using bash(Fedora 3). I have set an enviroment variable using: export temp='Helo world' How do I remove temp from enviroment? I guess this can be done in csh using unsetenv. One more question: Whats the difference between the output of a set and export with out options. (Both of them print all the environment variables. export just prints all the variables prefixed with 'declare -x'. What is it meant for?) |
env --unset=helo world
To remove variable helo world. :) |
unset temp
|
Hi bosewicht,
I tried your suggestion ie env --unset=temp. But it just printed all the environment variables without unsetting temp. Hi foo_bar_foo, thanks for the reply. It works |
How do I delete all Variables?
|
You really don't want to. If you unset your PATH, for example, you won't be able to run any applications and you might have a ton of trouble putting it back.
I suggest running the 'env' command to list all variables defined on your system and unset only the ones you know you don't need or want. With Linux, it's generally a very bad idea to delete something when you don't know what it is\does. |
Quote:
Code:
#!/bin/tcsh -f |
Unset ALL environment variables in BASH (not a good idea!):
Code:
$ unset `env | awk -F= '/^\w/ {print $1}' | xargs` |
All times are GMT -5. The time now is 02:39 AM. |