shell引入外部脚本

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"

猜你喜欢

转载自blog.csdn.net/qq_34500270/article/details/83011251
今日推荐