Muhammad Raihan Muhaimin
Muhammad Raihan Muhaimin

Reputation: 5729

What is the meaning of ". filename" (period space filename) in Bash?

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?

Upvotes: 15

Views: 7339

Answers (1)

Muhammad Raihan Muhaimin
Muhammad Raihan Muhaimin

Reputation: 5729

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.

Upvotes: 13

Related Questions