source
Reads and executes commands from the specified file in the current shell environment.
Summary
source filename [arguments]
The main purpose
Parameters
filename: file to be executed
arguments (optional): parameters passed to the file
return value
source returns the return value of the last command in the file. It will fail if the file cannot be read.
Incorrect usage
example
[root@localhost ~]# source ~/.bash_profile
Q&A
Q: What is the difference between source and sh in executing files?
A: sh is executed in a subshell. source will cause the variables and functions of the executed file to be loaded into the current terminal environment (excluding variables modified by local in the function, etc.); it is recommended that you refer to the export command. Knowledge Points Section
Notice
-
This command is a built-in bash command. For related help information, please see the
helpcommand.


