linux shell编程之修改环境变量

简介:
啥都别说,上代码先
#!/bin/bash
dir=${PWD}
icepath=/opt/ICE/bin
oraclehome=/opt/instantclient_11_2
icehome=/opt/ICE
pypath=/opt/IcePy-3.2.1/python
boostpath=/usr/local/boost_143
boostlib=$boostpath/lib
icelib=$icehome/lib
bfinder=`echo $PATH|grep $dir`
echo $bfinder
if [ "$bfinder" == "" ]
then
echo "export PATH=/$PATH:${dir}" >> ~/.bash_profile
export PATH=$PATH:${dir}
fi

bfinder=`echo $PATH|grep $icepath`
if [ "$bfinder" == "" ]
then
echo "export PATH=/$PATH:${icepath}" >> ~/.bash_profile
export PATH=$PATH:${icepath}
else
echo "ice path have been include"
fi

bfinder=`echo $ORACLE_HOME|grep $oraclehome`
if [ "$bfinder" == "" ]
then
echo "export ORACLE_HOME=${oraclehome}">>~/.bash_profile
export ORACLE_HOME=${oraclehome}
fi

bfinder=`echo $ICE_HOME|grep $icehome`
if [ "$bfinder" == "" ]
then
echo "export ICE_HOME=${icehome}">>~/.bash_profile
export ICE_HOME=${icehome}
fi

bfinder=`echo $PYTHONPATH|grep $pypath`
if [ "$bfinder" == "" ]
then
echo "export PYTHONPATH=${pypath}">>~/.bash_profile
export PYTHONPATH=${python}
fi
重要知识点 export只对当前shell有效,
所以结束之后需要source ~/.bash_profile


本文转自elbertchen 51CTO博客,原文链接:http://blog.51cto.com/linkyou/751872,如需转载请自行联系原作者
相关文章
|
1天前
|
网络协议 Shell Linux
LabVIEW 在NI Linux实时设备上访问Shell
LabVIEW 在NI Linux实时设备上访问Shell
|
2天前
|
存储 Unix Shell
Linux:环境变量
Linux:环境变量
19 7
|
3天前
|
Shell Linux
【Linux】进程实践项目(更新中) — 自主shell编写
前几篇文章,我们学习进程的相关知识:进程概念,进程替换,进程控制。熟悉了进程到底是个什么事情,接下来我们来做一个实践,来运用我们所学的相关知识。这个项目就是手搓一个shell模块,模拟实现Xshell中的命令行输入。
10 1
|
3天前
|
监控 关系型数据库 Shell
Shell脚本入门:从基础到实践,轻松掌握Shell编程
Shell脚本入门:从基础到实践,轻松掌握Shell编程
|
3天前
|
Shell Linux 信息无障碍
5 个有用的 Linux Shell 转义序列
5 个有用的 Linux Shell 转义序列
|
4天前
|
存储 算法 网络协议
【探索Linux】P.26(网络编程套接字基本概念—— socket编程接口 | socket编程接口相关函数详细介绍 )
【探索Linux】P.26(网络编程套接字基本概念—— socket编程接口 | socket编程接口相关函数详细介绍 )
12 0
|
5天前
|
Shell Linux 编译器
C语言,Linux,静态库编写方法,makefile与shell脚本的关系。
总结:C语言在Linux上编写静态库时,通常会使用Makefile来管理编译和链接过程,以及Shell脚本来自动化构建任务。Makefile包含了编译规则和链接信息,而Shell脚本可以调用Makefile以及其他构建工具来构建项目。这种组合可以大大简化编译和构建过程,使代码更易于维护和分发。
23 5
|
5天前
|
存储 Shell C语言
shell脚本 编程 变量 基本入门(详解)
shell脚本 编程 变量 基本入门(详解)
|
5天前
|
Linux Shell 程序员
【Linux】权限(shell运行原理、概念,Linux权限)
【Linux】权限(shell运行原理、概念,Linux权限)
14 2
|
6天前
|
存储 运维 Java
Linux笔记02 —— Shell补充
Linux笔记02 —— Shell补充
31 2