What does a command with format [period][space][filename] mean?
Example:
. ./setup.sh
Also in the .bashrc
file, we have a line like that:
. "$HOME/.bashrc"
What does this mean?
The dot command ( . ), aka full stop or period, is a command used to evaluate commands in the current execution context. In Bash, the source command is synonym to the dot command ( . ) and you can also pass parameters to the command, beware, this deviate from the POSIX specification.
The . ("dot") command is a synonym/shortcut for the shell's built-in source command. It causes the named shell script to be read in and executed within the current shell context (rather than a subshell).
Whitespace — this is a tab, newline, vertical tab, form feed, carriage return, or space. Bash uses whitespace to determine where words begin and end. The first word is the command name and additional words become arguments to that command.
The dot in that situation is part of the filename and has in the Linux/Unix context the meaning that the file or directory is hidden, you cannot see it in the file explorer (Nautilus, which is default on the vanilla Ubuntu), unless you press CTRL + H .
The .
operator is also known as source
.
According to this forum thread, the first .
is the command source
to read and execute commands from the filename given as argument.
The second .
is the current directory.
. ./setup.sh
is the same as
source ./setup.sh
or
source setup.sh
if the ./
, the current directory, is in the PATH
environment variable.
Here is the manual for that: http://ss64.com/bash/source.html
This is typically used to run the script in the current shell to help set up the environment for execution, as well as to set up aliases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With