shell引入外部脚本的四种方法
test.sh脚本如下
#!/bin/bash
name="This is test1"
#引入外部脚本的四种方式
#第一种
. test.sh
#第二种
source test.sh
#第三种
. ./test.sh
#第四种
source ./test.sh
test2.sh脚本,导入外部脚本test.sh
#!/bin/bash
source ./test.sh
echo "output: $name"
shell引入外部脚本的四种方法
test.sh脚本如下
#!/bin/bash
name="This is test1"
#引入外部脚本的四种方式
#第一种
. test.sh
#第二种
source test.sh
#第三种
. ./test.sh
#第四种
source ./test.sh
test2.sh脚本,导入外部脚本test.sh
#!/bin/bash
source ./test.sh
echo "output: $name"