什么是第一个’。’ 意思是’。 在〜/ .bashrc’?

我看到一篇关于在.bashrc修复你的别名的post。

他说你把别名放在.bashrc ,你需要使用:

 . ~/.bashrc 

我不太清楚第一个点(’。’)在这里做了什么。 它的function是什么?它叫什么?

有意思……名称似乎是dot-command ,在你的情况下,它包含.bashrc到调用shell程序(在你的情况下,你的bash环境)。 当您从命令行调用它时,它会更新您的环境变量,因为变量是在.bashrc中设置的。

 echo "FOO=bar" > test echo $FOO 

没有结果,env变量没有设置。 但在您获取“test”文件之后:

 . test 

设置env变量FOO

 echo $FOO 

导致输出

 bar 

我在这里找到了以下信息:

获取文件(dot-command)将代码导入脚本,附加到脚本(与C程序中的#include指令相同)。 最终结果与“源”代码行实际存在于脚本正文中的情况相同。 这在多个脚本使用公共数据文件或函数库的情况下非常有用。

另外,请看这个问题 。 在bash , .source相同。

如果你想用bash检查一些东西,请使用typeman

在你的情况下你想知道是什么。

 $ type . . is a shell builtin 

shell builtin意味着bash shell里面。 您可以在bash手册页中找到有关shell builtins的信息。 有一大段SHELL BUILTIN COMMANDS

 $ man bash SHELL BUILTIN COMMANDS Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options. The :, true, false, and test builtins do not accept options and do not treat -- specially. The exit, logout, break, continue, let, and shift builtins accept and process arguments beginning with - with‐ out requiring --. Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with - as invalid options and require -- to prevent this interpretation. : [arguments] No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned. . 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 exe‐ cuted from filename. If filename does not contain a slash, filenames 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 posi‐ tional 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.