使用'。'执行unix shell脚本时会发生什么。命令?

时间:2022-11-15 21:44:33

For e.g., when I say ". .bashrc" on my linux command prompt, is there a corresponding binary/script that gets executed in place of the first dot? If the dot itself is a command, where is its location?

例如,当我在linux命令提示符下说“.bashrc”时,是否有相应的二进制/脚本代替第一个点执行?如果点本身是一个命令,它的位置在哪里?

2 个解决方案

#1


The . operator is shorthand for the source Bash builtin (as pointed out by John Kugelman below). Typing

的。运算符是源Bash内置的简写(正如John Kugelman在下面指出的那样)。打字

help .

or

help source

at the Bash prompt will give you some information. For more on how source works, see http://www.ss64.com/bash/period.html.

在Bash提示符下会给你一些信息。有关源如何工作的更多信息,请参阅http://www.ss64.com/bash/period.html。

#2


Additionally I want to point out that you don't "execute" anything with it (in terms of fork/exec), which is very important (and probably the only reason '.' exists).

另外我想指出你不用它来“执行”任何东西(就fork / exec而言),这非常重要(可能是'。'存在的唯一原因)。

#1


The . operator is shorthand for the source Bash builtin (as pointed out by John Kugelman below). Typing

的。运算符是源Bash内置的简写(正如John Kugelman在下面指出的那样)。打字

help .

or

help source

at the Bash prompt will give you some information. For more on how source works, see http://www.ss64.com/bash/period.html.

在Bash提示符下会给你一些信息。有关源如何工作的更多信息,请参阅http://www.ss64.com/bash/period.html。

#2


Additionally I want to point out that you don't "execute" anything with it (in terms of fork/exec), which is very important (and probably the only reason '.' exists).

另外我想指出你不用它来“执行”任何东西(就fork / exec而言),这非常重要(可能是'。'存在的唯一原因)。