命令
source
描述
Execute commands from a file in the current shell
引用bash脚本或更新环境变量
用法
1 2
| source filename [arguments] . filename #也可以使用英文点符号
|
选项
无
注意
无
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| $ more a.sh a=3 $ more b.sh source ~/a.sh echo $a $ sh b.sh 3
$ grep ll ~/.bashrc alias ll='ls -al --color=auto' $ more b.sh ll source ~/.bashrc ll $ sh b.sh b.sh: line 1: ll: command not found total 52 dr-xr-x---. 3 root root 203 Dec 22 15:52 ./ dr-xr-xr-x. 17 root root 244 Oct 21 17:31 ../ -rw-r--r-- 1 root root 4 Dec 22 15:51 a.sh -rw------- 1 root root 5866 Dec 22 15:44 .bash_history -rw-r--r--. 1 root root 18 Dec 29 2013 .bash_logout -rw-r--r--. 1 root root 176 Dec 29 2013 .bash_profile -rw-r--r-- 1 root root 1053 Dec 22 14:44 .bashrc -rw-r--r-- 1 root root 23 Dec 22 15:52 b.sh
|