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

 

posted @ 2019-08-29 10:11  爱打盹的猫猫  阅读(108)  评论(0编辑  收藏  举报