如何删除导出的环境变量?

时间:2020-12-04 23:07:53

Before installing gnuplot, I set the environment variable GNUPLOT_DRIVER_DIR = /home/gnuplot/build/src. During the installation, something went wrong.

在安装gnuplot之前,我设置了环境变量GNUPLOT_DRIVER_DIR = /home/gnuplot/build/src。在安装过程中,出现了一些问题。

I want to remove the GNUPLOT_DRIVER_DIR environment variable. How can I achieve it?

我想删除GNUPLOT_DRIVER_DIR环境变量。我怎样才能做到呢?

3 个解决方案

#1


1754  

unset is the command you're looking for.

unset是您正在寻找的命令。

unset GNUPLOT_DRIVER_DIR

#2


139  

Walkthrough of creating and deleting an environment variable in bash:

Test if the DUALCASE variable exists:

测试DUALCASE变量是否存在:

el@apollo:~$ env | grep DUALCASE
el@apollo:~$ 

It does not, so create the variable and export it:

它没有,因此创建变量并导出它:

el@apollo:~$ DUALCASE=1
el@apollo:~$ export DUALCASE

Check if it is there:

检查是否有:

el@apollo:~$ env | grep DUALCASE
DUALCASE=1

It is there. So get rid of it:

它就在那里。所以摆脱它:

el@apollo:~$ unset DUALCASE

Check if it's still there:

检查它是否还在:

el@apollo:~$ env | grep DUALCASE
el@apollo:~$ 

The DUALCASE exported environment variable is deleted.

删除了DUALCASE导出的环境变量。

Extra commands to help clear your local and environment variables:

Unset all local variables back to default on login:

在登录时取消所有本地变量的默认设置:

el@apollo:~$ CAN="chuck norris"
el@apollo:~$ set | grep CAN
CAN='chuck norris'
el@apollo:~$ env | grep CAN
el@apollo:~$
el@apollo:~$ exec bash
el@apollo:~$ set | grep CAN
el@apollo:~$ env | grep CAN
el@apollo:~$

exec bash command cleared all the local variables but not environment variables.

exec bash命令清除所有本地变量,但不清除环境变量。

Unset all environment variables back to default on login:

将所有环境变量重置为默认登录:

el@apollo:~$ export DOGE="so wow"
el@apollo:~$ env | grep DOGE
DOGE=so wow
el@apollo:~$ env -i bash
el@apollo:~$ env | grep DOGE
el@apollo:~$

env -i bash command cleared all the environment variables to default on login.

env -i - bash命令在登录时清除所有的环境变量。

#3


2  

this may also work.

这也可以工作。

export GNUPLOT_DRIVER_DIR=

#1


1754  

unset is the command you're looking for.

unset是您正在寻找的命令。

unset GNUPLOT_DRIVER_DIR

#2


139  

Walkthrough of creating and deleting an environment variable in bash:

Test if the DUALCASE variable exists:

测试DUALCASE变量是否存在:

el@apollo:~$ env | grep DUALCASE
el@apollo:~$ 

It does not, so create the variable and export it:

它没有,因此创建变量并导出它:

el@apollo:~$ DUALCASE=1
el@apollo:~$ export DUALCASE

Check if it is there:

检查是否有:

el@apollo:~$ env | grep DUALCASE
DUALCASE=1

It is there. So get rid of it:

它就在那里。所以摆脱它:

el@apollo:~$ unset DUALCASE

Check if it's still there:

检查它是否还在:

el@apollo:~$ env | grep DUALCASE
el@apollo:~$ 

The DUALCASE exported environment variable is deleted.

删除了DUALCASE导出的环境变量。

Extra commands to help clear your local and environment variables:

Unset all local variables back to default on login:

在登录时取消所有本地变量的默认设置:

el@apollo:~$ CAN="chuck norris"
el@apollo:~$ set | grep CAN
CAN='chuck norris'
el@apollo:~$ env | grep CAN
el@apollo:~$
el@apollo:~$ exec bash
el@apollo:~$ set | grep CAN
el@apollo:~$ env | grep CAN
el@apollo:~$

exec bash command cleared all the local variables but not environment variables.

exec bash命令清除所有本地变量,但不清除环境变量。

Unset all environment variables back to default on login:

将所有环境变量重置为默认登录:

el@apollo:~$ export DOGE="so wow"
el@apollo:~$ env | grep DOGE
DOGE=so wow
el@apollo:~$ env -i bash
el@apollo:~$ env | grep DOGE
el@apollo:~$

env -i bash command cleared all the environment variables to default on login.

env -i - bash命令在登录时清除所有的环境变量。

#3


2  

this may also work.

这也可以工作。

export GNUPLOT_DRIVER_DIR=