Shell学习八:调用其它shell文件

写法

. filename   # 注意点号(.)和文件名中间有一空格

或

source filename

实例

test1.sh 代码

#!/bin/bash

url="test1"

test2.sh 代码

#!/bin/bash

#使用 . 号来引用test1.sh 文件
. ./test1.sh

# 或者使用以下包含文件代码
# source ./test1.sh

echo "执行test1.sh:$url"

结果

$ chmod +x test2.sh 
$ ./test2.sh 
执行test1.sh:test1
原文地址:https://www.cnblogs.com/hubwang/p/13297862.html