Linux export 命令
来源:互联网 发布:谢谢的网络用语2017 编辑:程序博客网 时间:2024/04/30 12:09
shell与export命令
用户登录到Linux系统后,系统将启动一个用户shell。在这个shell中,可以使用shell命令或声明变量,也可以创建并运行shell脚本程序。运行shell脚本程序时,系统将创建一个sub-shell。此时,系统中将有两个shell,一个是登录时系统启动的shell,另一个是系统为运行脚本程序创建的shell。当一个脚本程序运行完毕,它的脚本shell将终止,可以返回到执行该脚本之前的shell。从这种意义上来说,用户可以有许多 shell,每个shell都是由某个shell(称为父shell)派生的。
在sub-shell中定义的变量只在该sub-shell内有效。如果在一个shell脚本程序中定义了一个变量,当该脚本程序运行时,这个定义的变量只是该脚本程序内的一个局部变量,其他的shell不能引用它,要使某个变量的值可以在其他shell中被改变,可以使用export命令对已定义的变量进行输出。
export命令将使系统在创建每一个新的shell时定义这个变量的一个拷贝。这个过程称之为变量输出。
[例]在本例中,变量myfile是在dispfile脚本程序中定义的。然后用export命令将变量myfile输出至任何sub-shell,例如当执行printfile脚本程序时产生的sub-shell。
dispfile脚本程序清单:
/**************begin dispfile**************/
myfile=”List”
export myfile
echo “Displaying $myfile”
pr –t –n $myfile
printfile
/**************end dispfile***************/
printfile脚本程序清单:
/**************begin printfile**************/
echo “Printing $myfile”
lpr $myfile&
/**************end printfile**************/
$dispfile
Displaying List
1 screen
2 modem
3 paper
Printing List
$
- linux source,export命令
- Linux export 命令
- Linux export 命令
- linux 之 export命令
- Linux命令:export用法
- Linux export命令
- Linux export 命令
- linux命令:export
- Linux export 命令
- export命令-linux
- Linux export 命令
- Linux export命令详解
- LINUX export命令
- Linux export命令
- Linux export 命令
- Linux export命令
- Linux export 命令
- Linux export命令
- InstallShield常用常量
- 如何为IDE注册第三方Silverlight控件
- Too many connections错误的解决办法
- 一个Windows C++的线程类实现
- 数据库的连接问题
- Linux export 命令
- 你是如何让position:fixed在IE6中工作的?
- android中去掉标题栏和状态栏,实现全屏
- 百万数据查询优化技巧三十则(从朋友那转来的)
- 第三章 t-sql程序设计基础 批处理与用户自定义函数
- Zend Framework 项目目录结构
- ArrayList Array List性能比较
- 研究
- 我是清华大学的学生