Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

bash

period

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?

like image 906
Muhammad Raihan Muhaimin Avatar asked Jun 09 '13 21:06

Muhammad Raihan Muhaimin


People also ask

What is period in Bash?

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.

What is dot space filename in Linux?

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).

What is space in Bash?

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.

What does period mean in Linux?

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 .


1 Answers

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.

like image 81
Muhammad Raihan Muhaimin Avatar answered Oct 24 '22 06:10

Muhammad Raihan Muhaimin