leeboy的linux学习十三环境变量实例
2012-09-11 16:04
253 查看
环境变量和本地变量的区别在于是不是具有继承性,下面介绍一个环境变量的例子:
exportFather父进程:
exportChild 子进程:
执行结果如下:
如果我想在子进程中修改的环境变量也能影响到主进程的改环境变量,该如何做呢?望大牛指导!
exportFather父进程:
#!/bin/sh #father script echo "this is the father" FILE="A GOOD MAN" echo "I like the file : $FILE" export FILE #声明为环境变量,如果此处不声明,exportChild无法使用该变量 ./exportChild #执行子进程 echo "back to father" echo "and the file is : $FILE"
exportChild 子进程:
#!/bin/sh #child file echo "this is Child" echo "I like my father's file : $FILE" FILE="Child File" #子进程中修改该环境变量对主进程中没有影响 echo "my file is : $FILE"
执行结果如下:
[root@localhost textFile]# ./exportFather this is the father I like the file : A GOOD MAN this is Child I like my father's file : A GOOD MAN my file is : Child File back to father and the file is : A GOOD MAN //环境变量在子进程中修改但父进程中没有变化
如果我想在子进程中修改的环境变量也能影响到主进程的改环境变量,该如何做呢?望大牛指导!
相关文章推荐
- leeboy的linux学习十二环境及环境变量
- linux 学习:环境变量设置
- Linux学习——环境变量设置
- 实验楼linux学习笔记(五) 环境变量与文件查找
- Linux学习之环境变量
- linux 学习 : 创建linux 环境变量
- Java学习笔记--解析JDK与IDE(Linux下Java环境变量的配置)
- linux基本变量学习:位置变量$0 、$1 shift轮替、本地变量、环境变量、特殊变量
- linux学习笔记入门之环境变量和文件查找
- [Linux学习]linux下环境变量的设置
- 【Linux学习笔记】34:登录时生效的环境变量配置文件 上
- LINUX C 学习笔记-2-从环境变量开始-高级篇
- leeboy的linux学习九sed实例
- 实验楼Linux学习笔记(四)之环境变量与文件查找
- Linux学习之十一、环境变量的功能
- Linux学习总结(十)-文件复制及查看, 环境变量
- leeboy的linux学习七awk实例
- Linux学习——shell编程之环境变量配置文件
- Linux学习笔记 1 环境变量 2 vi命令
- Linux学习——shell编程之环境变量配置文件