The difference souce and bash

For some environment variables configuration files, such as to make the change take effect immediately, the use souce + file immediately after execution. The / etc / profile configuration Riga,

source and bash difference:

the difference between source filename and sh filename and ./filename execute scripts in there?
1. When the shell script has executable permissions with sh filename and ./filename execution of the script is no difference, too. ./filename is because the current directory is not in the PATH, all. "" is used to indicate the current directory.
2.sh filename to re-establish a sub-shell, execute the script inside the statement in the sub-shell, the shell sub-shell environment variables inherited his father's, but the new sub-shell, change variables will not be brought back to the parent shell, unless export .
3.source filename: This command is really just simply read the script inside the statement sequentially executed in the current shell inside, not creating a new sub-shell. The script all new inside, change the variable of statement will be saved in the current shell inside.

Guess you like

Origin www.cnblogs.com/brucewhite/p/11608952.html