shell文件包含

格式:

. filename(.和filename间需要空格)或者 source filename

[root@ipha-dev71-1 exercise_shell]# cat test1.sh 
#!/bin/sh
url="http://www.baidu.com"
[root@ipha-dev71-1 exercise_shell]# cat test2.sh 
#!/bin/bash
. ./test1.sh
#source ./test1.sh
echo "百度的网址:${url}"
[root@ipha-dev71-1 exercise_shell]# ./test2.sh 
百度的网址:http://www.baidu.com
原文地址:https://www.cnblogs.com/wang-mengmeng/p/11428089.html