$ whatis source
source: nothing appropriate.
$ man source
No manual entry for source
$ source
bash: source: filename argument required
source: usage: source filename [arguments]
它存在,并且可以运行。为什么 Ubuntu 中没有关于它的任何文档?它有什么用?我如何安装有关它的文档?
答案1
source
是 Bash shell 内置命令,执行作为参数传递的文件内容在当前 shell 中.
。它在(句号)中有一个同义词。
句法
. filename [arguments] source filename [arguments]
答案2
小心!./
并且source
不太一样。
./script
将脚本作为可执行文件运行,启动新壳运行它source script
读取并执行来自 filename 中的命令当前外壳环境
注意:./script
不是. script
,但是. script
==source script
答案3
了解‘type’命令很有用:
> type source
source is a shell builtin
每当某些东西是 shell 内置的,就该这么做了man bash
。
答案4
'source' 是 '.' 命令的长版本。在 bash 提示符下可以执行:
source ~/.bashrc
重新加载(已更改?)当前正在运行的 bash 的 bash 设置。
简短版本如下:
. ~/.bashrc
手册页:
. filename [arguments]
source filename [arguments]
Read and execute commands from filename in the current shell environment and
return the exit status of the last command executed from filename. If
filename does not contain a slash, file names in PATH are used to find the
directory containing filename. The file searched for in PATH need not be
executable. When bash is not in posix mode, the current directory is
searched if no file is found in PATH. If the sourcepath option to the shopt
builtin command is turned off, the PATH is not searched. If any arguments
are supplied, they become the positional parameters when filename is
executed. Otherwise the positional parameters are unchanged. The return
status is the status of the last command exited within the script (0 if no
commands are executed), and false if filename is not found or cannot be
read.