As everyone is saying:
. myfile
: executes commands from myfile
. (Like the source
command in
C Shell)
./myfile
: executes myfile
To elaborate, .
is a command by itself (and myfile
is passed as an argument to that), where ./
is a (relative) path to a file. When executing ./myfile
you are executing myfile
which is an executable and is located in your current directory.
With that being said, when you want to execute some executable like a.out
(which I assume is a C or C++ executable or something similar) you type ./a.out
.
When you have a bunch of commands in a "text" file and you want your shell to run those, you type . myfile
. The most profound example of that is probably when you change the contents of .bashrc
or .profile
files and you want to "apply" your changes to the system.
Finally, do not confuse .
command with .
which is your current directory (as in the first result of ls -a
)
a.out
would be in a subdirectoryb
, you can run it usingb/a.out
- suddenly there's not dot but it's the same command as./a.out
). – David Ferenczy Rogožan Feb 8 '18 at 18:19