标签:source sh .
vim test.sh
#!/bin/bash
a=12.然后使其可执行chmod +x test.sh3.运行sh test.sh后,echo $a,显示为空,因为a=1并未传回给当前shell4.运行./test.sh后,也是一样的效果5.运行source test.sh 或者 . test.sh,然后echo $a,则会显示1,说明a=1的变量在当前shell中
Linux source命令与脚本的执行方式对比
原文地址:http://blog.51cto.com/13452945/2074273