001、
Linuxbash和source命令的区别在于,当你用bash命令执行脚本时,它告诉Linux内核创建一个新的Bash进程来读取和执行脚本,将输出复制到原先的shell进程中,并显示下来.
然而source命令是一个外置的shell,它读取和评估当前shell进程中的文件。为此,脚本所做的所有修改都将保留在Bashshell中。
a、bash
[root@PC1 test2]# ls test.txt [root@PC1 test2]# cat test.txt var1=100 echo $var1 [root@PC1 test2]# echo $var1[root@PC1 test2]# bash test.txt 100 [root@PC1 test2]# echo $var1
。
b、source