How do I delete an exported environment variable?
unset
is the command you're looking for.
unset GNUPLOT_DRIVER_DIR
Walkthrough of creating and deleting an environment variable in Bash:
Test if the DUALCASE variable exists (empty output):
env | grep DUALCASE
It does not, so create the variable and export it:
DUALCASE=1
export DUALCASE
Check if it is there:
env | grep DUALCASE
Output:
DUALCASE=1
It is there. So get rid of it:
unset DUALCASE
Check if it's still there (empty output):
env | grep DUALCASE
The DUALCASE exported environment variable is deleted.
Extra commands to help clear your local and environment variables:
Unset all local variables back to default on login:
CAN="chuck norris"
set | grep CAN
Output:
CAN='chuck norris'
env | grep CAN # Empty output
exec bash
set | grep CAN
env | grep CAN # Empty output
exec bash
command cleared all the local variables, but not environment variables.
Unset all environment variables back to default on login:
export DOGE="so wow"
env | grep DOGE
Output:
DOGE=so wow
env -i bash
env | grep DOGE # Empty output
env -i bash
command cleared all the environment variables to default on login.