shell 文件包含
包含外部脚本(包含的脚本可以不需要可执行权限)
source filename
示例:
$ cat demo.sh #! /bin/bash function fun() { echo "this is a function" } fun $ cat test.sh #! /bin/bash source ./demo.sh fun $ ./test.sh this is a function this is a function
包含外部脚本(包含的脚本可以不需要可执行权限)
source filename
示例:
$ cat demo.sh #! /bin/bash function fun() { echo "this is a function" } fun $ cat test.sh #! /bin/bash source ./demo.sh fun $ ./test.sh this is a function this is a function