./test.sh . ./test.sh source ./test.sh的区别
背景
今天写几个shell脚本,使用一个公共的config.sh,但是export出来的东西在另外的*.sh中不能直接用,这让我很惆怅,印象中就是可以export出来给别的shell用啊,只要不是下一次就行啊。。。
查资料
果然是我图样图森破啊,知识半吊子水都没啊。
查到这样一篇http://blog.csdn.net/dance_rise/article/details/8573560
结论
./test.sh就是bash test.sh,在子进程中执行. ./test.sh与source ./test.sh的功能相同,在当前进程中执行
在shell里调用另外一个.sh是在子进程中运行的,即使export出去,也不能被父进程使用。
./test.sh . ./test.sh source ./test.sh的区别的更多相关文章
- linux中fork, source和exec的区别
转:linux中fork, source和exec的区别 shell的命令可以分为内部命令和外部命令. 内部命令是由特殊的文件格式.def实现的,如cd,ls等.而外部命令是通过系统调用或独立程序实现 ...
- linux里source、sh、bash、./有什么区别
在linux里,source.sh.bash../都可以执行shell script文件,那它们有什么不同吗? ----------- 1.source source a.sh 在当前shell内去读 ...
- shell中source与sh区别
shell中使用source conf.sh,是直接运行conf.sh的命令,不创建子shell,类似与html中include,而sh是则创建子shell, 子shell里面 的变量父shell无法 ...
- source 和sh 区别
sh新建一个子shell进程,变量在主shell中无法获取 source在当前shell中执行脚本,变量在主shell即当前shell中可以获取 例子: 1.新建一个test.sh脚本,内容为:A=1 ...
- source、sh、bash
source.sh.bash../ 执行脚本的区别 1.source命令用法: source FileName 作用:在当前bash环境下读取并执行FileName中的命令.该filename文件可以 ...
- linux里source、sh、bash、./有什么区别(转)
add by zhj: 主要不同是,source是在当前shell中执行脚本,而sh, bash, ./是在当前shell的child shell中执行脚本 原文:http://www.cnblogs ...
- [Shell Script]关于source和sh对于脚本执行不同
当我修改了/etc/profile文件,我想让它立刻生效,而不用重新登录:这时就想到用source命令,如:source /etc/profile对source进行了学习,并且用它与sh 执行脚本进行 ...
- (转)source、sh、bash、./执行脚本的区别
source.sh.bash../执行脚本的区别 原文:https://www.cnblogs.com/sparkbj/p/5976100.html 1.source命令用法: source Fil ...
- source和sh执行脚本时的差异
在CentOS7下,有如下脚:sh02.sh. 1 用sh或者bash执行 先执行echo $firstname $lastname 再执行 sh sh02.sh 最后执行 echo $firstna ...
随机推荐
- HCharts的y轴保留一位和 两位小数
保留一位小数,有一位小数的不变 yAxis : { labels : { formatter : function () { var strVal = ''+this.value ; if (str ...
- Flex slider参数详细
$(window).load(function() { $('.flexslider').flexslider({ animation: "fade", //String: Sel ...
- [译]lambda表达式对 SAM (单个抽象方法类)type的处理方式
在阅读Venkat Subramaniam的著作<Functional Programming in Java> 之后,方法模式和lambda完美结合让我印象深刻. 这种模式经常用作数据源 ...
- CentOS7配置阿里云yum源和EPEL源
配置阿里云yum源(参考:http://mirrors.aliyun.com/help/centos) 1.备份 [root@bogon ~]# cd /etc/yum.repos.d/ [root@ ...
- hdu 5178(二分-lower_bound,upper_bound)
pairs Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- php7使用curl
/** * @param string $url * @return mixed */ public function doGet($url) { //初始化 $ch = curl_init(); c ...
- (一)mysql基础和安装mysql5.7
(1)数据库系统 RDS:关系型,oracle,mysql,mariaDB,percona server ,DB2 NoSQL:Redis,MongoDB,memcache (2)SQL语言:结构化查 ...
- saturate_cast防越界函数
CV_IMAGE_ELEM(img2,uchar,i,j*3+c)=saturate_cast<uchar>(alpha*( CV_IMAGE_ELEM(img,uchar,i,j*3+c ...
- 百度之星资格赛 2016 Problem 1002
本文链接:http://www.cnblogs.com/Ash-ly/p/5494623.html 题意: 度熊面前有一个全是由1构成的字符串,被称为全1序列.你可以合并任意相邻的两个1,从而形成一个 ...
- Coderforces 85 D. Sum of Medians(线段树单点修改)
D. Sum of Medians time limit per test 3 seconds memory limit per test 256 megabytes input standard i ...