linux shell脚本 引入外部shell文件

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
 

相关文章

在Linux系统中,设置ARP防火墙可以通过多种方法实现,包括使...
在Linux环境下,使用Jack2进行编译时,可以采取以下策略来提...
`getid`命令在Linux系统中用于获取当前进程的有效用户ID(EU...
在Linux环境下,codesign工具用于对代码进行签名,以确保其完...
Linux中的`tr`命令,其英文全称是“transform”,即转换的意...
Linux中的ARP防火墙是一种用于防止ARP欺骗攻击的安全措施,它...