读书人

linux,unix设立,新增,删除,环境变量的

发布时间: 2012-07-24 17:47:58 作者: rapoo

linux,unix设置,新增,删除,环境变量的脚本
#~~~~~~~~~~~~~~~~~~~~~新建环境变量

linux终端下:

vi setEnv.sh

#~~~~~

内容如下:


cd /etc
FIVE_TWO_ZERO=$2
export FIVE_TWO_ZERO
if [ -f "profile" ]
then
echo "">>profile
echo "FIVE_TWO_ZERO=$FIVE_TWO_ZERO">>.profile
echo "export FIVE_TWO_ZERO">>profile
fi
保存后
输入:
./setEnv.sh /root/test
即可新增环境变量
可用 cat /etc/profile命令查看
#~~~~~~~~~~~~~~~~删除环境变量
vi rmEnv.sh
cd /etc
if [ -f "profile" ]
then
sed '/FIVE_TWO_ZERO/d' profile > profile.tempforinforsuite
cat profile.tempforinforsuite > profile
fi
source /etc/profile
cd ~
source .bash_profile
#
保存后
输入:
./rmEnv.sh
即可删除环境变量
可用 cat /etc/profile命令查看

读书人网 >UNIXLINUX

热点推荐