Wednesday, May 8, 2024
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 3243  / 1 Year ago, sat, january 7, 2023, 2:48:22

I saw a post about fix your alias in .bashrc.



And he says after you put your alias in .bashrc , you need to use:



. ~/.bashrc


I do not quite understand what the first dot(' . ') does here. What's its function and what is it called?


More From » command-line

 Answers
0

Interesting... the name seems to be dot-command, in your case it includes the .bashrc into the calling shell program (in your case, your bash environment). As you are calling it from the command line, it updates your environmental variables, as variables are set in .bashrc.



echo "FOO=bar" > test
echo $FOO


no result, env variable not set. But after you source the "test" file:



. test


the env variable FOO is set and



echo $FOO


result in the output of



bar


I found the following info here:



Sourcing a file (dot-command) imports code into the script, appending to the script (same effect as the #include directive in a C program). The net result is the same as if the "sourced" lines of code were physically present in the body of the script. This is useful in situations when multiple scripts use a common data file or function library.



Also, see this question. In bash, . is the same as source.


[#24112] Sunday, January 8, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
whoppinolo

Total Points: 93
Total Questions: 113
Total Answers: 107

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
;