スクリプトの中に入れるだけです:
source FILE
または
. FILE # POSIX compliant
$ 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.
上記の回答は正しいですが、スクリプトを別のフォルダーで実行すると、問題が発生します。
例:a.sh そして b.sh 同じフォルダにあり、. ./b.sh を使用 b.を含める
xx/xx/xx/a.sh などのフォルダからスクリプトを実行すると、 、ファイル b.sh 見つかりません:./b.sh: No such file or directory .
だから私は使う
. $(dirname "$0")/b.sh