如何将文件包含在bash shell脚本中
有没有办法在shell脚本中包含另一个shell脚本来访问它的function?
就像在PHP中一样,您可以将include指令与其他PHP文件一起使用,以便通过调用函数名称来运行包含的函数。 
简单地把你的脚本放进去:
 source FILE 
要么
 . FILE 
这是同一件事。
 $ LANG=C help source source: source filename [arguments] Execute commands from a file in the current shell. Read and execute commands from FILENAME in the current shell. The entries in $PATH are used to find the directory containing FILENAME. If any ARGUMENTS are supplied, they become the positional parameters when FILENAME is executed. Exit Status: Returns the status of the last command executed in FILENAME; fails if FILENAME cannot be read. 
 是的,使用源或简称.  : 
 . other_script.sh 
以上答案是正确的,但是如果在其他文件夹中运行脚本,会出现一些问题。
 例如, b.sh和b.sh在同一个文件夹中,一个包含b . ./b.sh  . ./b.sh包含。 
 将脚本从文件夹中运行时,例如使用xx/xx/xx/a.sh b.sh将找不到./b.sh: No such file or directory 。 
我用
 . $(dirname "$0")/b.sh