For example, 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?
Asked
Active
Viewed 1,393 times
4

Benjamin W.
- 46,058
- 19
- 106
- 116

Harty
- 316
- 2
- 12
-
1I do not think the 'belongs-on-serverfault' tag is appropriate here. Shell scripting is a valid programming topic. – Sinan Ünür Jul 10 '09 at 05:15
-
Been asked and answered a couple of time already. Good luck finding the dups, though... – dmckee --- ex-moderator kitten Jul 10 '09 at 17:15
-
Found one: http://stackoverflow.com/questions/922651/unix-command-line-execute-with-dot-vs-without – dmckee --- ex-moderator kitten Jul 10 '09 at 17:15
-
Surprised why it didn't show up when I searched for it :-). Something for Jeff & team to chew on? Am not sure if I should edit the earlier question, or leave this one as is, so there's a greater chance of someone finding the question. – Harty Jul 15 '09 at 04:35
-
related: http://superuser.com/questions/176783/what-is-the-difference-between-executing-a-bash-script-and-sourcing-a-bash-scrip/176788#176788 – Lesmana Dec 04 '11 at 18:35
-
Also see [this question](http://serverfault.com/questions/36052/what-is-the-purpose-of-source-as-a-shell-command) on Server Fault. – Dennis Williamson Jul 10 '09 at 09:44
2 Answers
10
The .
operator is shorthand for the source
Bash builtin (as pointed out by John Kugelman below). Typing
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.

Sinan Ünür
- 116,958
- 15
- 196
- 339
-
1+1 Key is that it is a shell builtin, not a separate binary. You can type `help` at a bash prompt to see all of the other builtins. – John Kugelman Jul 10 '09 at 05:16
3
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).

TheBonsai
- 15,513
- 4
- 22
- 14
-
3One key point - a consequence of the dot command not executing anything - is that if the dotted script sets variables, it sets them in the shell that dots the script, not in some sub-shell. – Jonathan Leffler Jul 10 '09 at 05:34