linux脚本 source,Shell中的source和.命令
source是csh(C Shell)的内置命令: 标识读入并执行文件中的命令。
这与执行shell脚本是不一样的./script.sh会启动一个新的shell并执行script.sh中的命令。
source [-h] filename [arguments]
The shell reads and executes commands from name. The commands
are not placed on the history list. If any args are given,
they are placed in argv. (+) source commands may be nested; if
they are nested too deeply the shell may run out of file
descriptors. An error in a source at any level terminates all
nested source commands. With -h, commands are placed on the
history list instead of being executed, much like `history -L'.
sh (Bourne Shell)和ksh (Korn Shell)有一个类似的命令 .
. filename [arguments]
The commands in the specified file are read and executed by the shell.
The return command may be used to return to the . command's caller.
If file contains any ''/'' characters, it is used as is. Otherwise, the shell
searches the PATH for the file. If it is not found in the PATH, it is sought
in the current working directory.
bash (GNU Bourne-Again
Shell)是组合了sh/ksh/csh的特征同时支持(source)命令和.命令。
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
