15

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?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Muhammad Raihan Muhaimin
  • 5,559
  • 7
  • 47
  • 68
  • 1
    From the bash manual, http://www.gnu.org/software/bash/manual/bashref.html#index-_002e – glenn jackman Jun 09 '13 at 23:39
  • possible duplicate of [What happens when I execute a unix shell script using a '.' command?](http://stackoverflow.com/questions/1107808/what-happens-when-i-execute-a-unix-shell-script-using-a-command) – chepner Apr 24 '14 at 21:45

1 Answers1

13

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.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
Muhammad Raihan Muhaimin
  • 5,559
  • 7
  • 47
  • 68