我看到了一篇关于在.bashrc中修复别名的帖子。
他说,在你把别名放入.bashrc之后,你需要使用:
我不太明白这里的第一个点(' . ')具体是做什么用的。它的功能是什么,它叫什么名字?
他说,在你把别名放入.bashrc之后,你需要使用:
. ~/.bashrc
我不太明白这里的第一个点(' . ')具体是做什么用的。它的功能是什么,它叫什么名字?
. ~/.bashrc
type
和man
。$ type .
. is a 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.
dot-command
,在你的情况下它将.bashrc包含到调用的shell程序中(在你的情况下,是你的bash环境)。由于你是从命令行调用它,它会更新你的环境变量,因为变量是在.bashrc中设置的。echo "FOO=bar" > test
echo $FOO
没有结果,环境变量未设置。但是在你加载了“test”文件之后:
. test
echo $FOO
bar
我在这里找到以下信息here:
使用文件(dot-command)进行源代码导入到脚本中,将其附加到脚本(与C程序中的#include指令具有相同效果)。最终结果等同于“source”代码行实际上存在于脚本主体中。这在多个脚本使用共享数据文件或函数库的情况下非常有用。
另请参阅question。在bash中,.
与source
相同。
. test
,你首先需要执行 chmod +x test
使其可执行。 - saiarcot895.
表示引用来源。 - Avinash Raj
bash
中,内置命令非常方便,其中help
内置命令也是一个很有用的工具:help .
- Eliah Kagan