Answers:
这是内建的同义词source。它将从当前Shell中的文件执行命令,如从help source或读取的命令help .。
在您的情况下,文件/etc/vz/vz.conf将被执行(很有可能,它仅包含变量分配,这些分配将在脚本的后面使用)。它与仅/etc/vz/vz.conf在许多方面执行文件不同,例如:最明显的是文件不需要可执行。那么您将考虑与之一起运行它,bash /etc/vz/vz.conf但这只会在子进程中执行它,并且父脚本将看不到子进程所做的任何修改(例如,对变量的修改)。
例:
$ # Create a file testfile that contains a variable assignment:
$ echo "a=hello" > testfile
$ # Check that the variable expands to nothing:
$ echo "$a"
$ # Good. Now execute the file testfile with bash
$ bash testfile
$ # Check that the variable a still expands to nothing:
$ echo "$a"
$ # Now _source_ the file testfile:
$ . testfile
$ # Now check the value of the variable a:
$ echo "$a"
hello
$
希望这可以帮助。
.是通用的,source并且用途广泛,但不能简单地使用sh。
.在大多数shell(sh,ash,ksh等)中均可使用,source专用于bash。