shell脚本 引入文件 文件包含的语法格式如下:

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

实例:

[root@hadoop01 shell]# vi test1.sh
 
#!/bin/bash                                                                                   
name=timo
 
[root@hadoop01 shell]# vi test2.sh
 
#!/bin/bash
tag="this is a boy"
 
[root@hadoop01 shell]# vi test3.sh
 
#!/bin/bash
. ./test1.sh
source ./test2.sh
echo $name$tag
 
[root@hadoop01 shell]# chmod a+x test3.sh 
[root@hadoop01 shell]# ./test3.sh
timothis is a boy
 

Logo

更多推荐