关于两种运行sh的方式: ./myscript.ksh and . ./myscript.ksh
来源:互联网 发布:k均值是关联规则算法 编辑:程序博客网 时间:2024/04/28 16:26
这个问题困扰我很久很久了。。。有时候用这个就行,有时候用那个才行,到底有什么区别?
Difference Between executing like ./myscript.ksh and . ./myscript.ksh (两个点之间有空格)
我参考了下面这两篇帖子:
http://www.unix.com/unix-dummies-questions-answers/156460-difference-between-executing-llike-myscript-ksh-myscript-ksh.html
http://publib.boulder.ibm.com/infocenter/zvm/v5r4/index.jsp?topic=/com.ibm.zvm.v54.dmsp3/comd672.htm
. myscript.ksh的意思是,Run a shell file in the current environment。
也就是说executes ksh in current shell. Since it's run in the current shell, any variables it sets, for example, are available in your current shell.
但我们常用的形式是. ./myscript.ksh (中间有空格). 这是因为文件名的缘故:
If there are slashes in the file name, . (dot) looks for the named file. If there are no slashes. (dot) uses the search PATH variableto findfile.
This may surprise some people when they use dot torun a file in the working directory, but their search rules are not set upto look at the working directory. As a result, the shell doesn't find theshell file. If you have this problem, you can use:
. ./myscript.ksh
因此上句的意思就是,使用current environment运行这个脚本,同时,在工作目录搜索该脚本。
所以现在很清楚了, ./myscript.ksh的意思是执行当前工作目录中的这个脚本,但是是在不同的shell中。
二者的不同会导致一个明显的区别:
如果在一个ksh中设置了一些变量,然后调用了:
ksh `. ./myscript.ksh` 那么之前设置的变量可以在子脚本,即myscript.ksh中使用。
如果调用的是:
ksh `./myscript.ksh` 那么之前设置的变量不能在myscript.ksh中使用。
- 关于两种运行sh的方式: ./myscript.ksh and . ./myscript.ksh
- 关于两种运行sh的方式: ./myscript.ksh and . ./myscript.ksh
- MyScript
- 关于KSH的数组
- ksh
- ksh
- sh-bash-resh-ksh
- 监控进程运行 KSH
- sh,ksh,csh三者之间的差异
- linux下如何对ksh和sh的切换
- sh/bash/csh/Tcsh/ksh/pdksh等shell的区别
- Ksh的几点小技巧
- ksh 的变量
- Linux + Shell bash / sh / ksh / csh / tcsh
- Linux + Shell bash / sh / ksh / csh / tcsh
- Unix/Unix Shell -- sh, ksh, csh
- AIX执行.sh文件 ksh not found
- 一个在ksh中运行java程序的例子
- 从c++转到Python需要注意的地方
- 系统维护常用配置文件
- jquery 强大插件
- HWND and HDC 以及 DC 释放问题
- 教你怎么看top命令-linux进度
- 关于两种运行sh的方式: ./myscript.ksh and . ./myscript.ksh
- shopex二次开发手册
- awk输出到多个文件
- mysql中pager的用法
- 利用opencv逼近二值图像的边界点,并过滤不需要的边界,达到寻边效果。(转载请说明出处)
- Oracle 开发常见问题
- Emacs 新闻组 之三 收发Gmail
- android入门-------案例七(alertdialog的使用)
- 凝聚力