Before installing gnuplot, I set the environment variable GNUPLOT_DRIVER_DIR = /home/gnuplot/build/src
. During the installation, something went wrong.
I want to remove the GNUPLOT_DRIVER_DIR
environment variable. How can I achieve it?
Delete Environment Variables You need to just use the unset command with the variable name to delete it. This command will remove the variable permanently.
The dsadmin command can be used for deleting an environment variable in a particular project.
Using the set -n command Alternatively, you can unset environment variables by using the set command with the “-n” flag.
unset
is the command you're looking for.
unset GNUPLOT_DRIVER_DIR
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.
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.
The original question doesn't mention how the variable was set, but:
In C shell (csh/tcsh) there are two ways to set an environment variable:
set x = "something"
setenv x "something"
The difference in the behaviour is that variables set with the setenv command are automatically exported to a subshell while variables set with set aren't.
To unset a variable set with set, use
unset x
To unset a variable set with setenv, use
unsetenv x
Note: in all the above, I assume that the variable name is 'x'.
Credits:
TCSH / CSH: set vs setenv Command Differences
set, unset, setenv, unsetenv, export — Shell Environment Variable Built-in Functions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With