We know that source is executing a script, so what's the difference between him and ordinary execution?
test1.sh
#!/bin/shexport kkk=111
General execution:
[Email protected]:~$./test1.sh[email protected]:~$ Echo $KKK
No results.
Source execution:
[Email protected]:~$ source Test1.sh[email protected]:~$ Echo $KKK 111
Have the result.
Why is that?
because./test1.shis in the childShellrun in, and did not reflect to the FatherShell, so I can't see the result.
but Source is in this Shell so that you can see the results.
Because of his "explicit" characteristics, source ( ) /span> typically used to re-execute the newly modified initialization document,
as . Bash_profile and the . profile and so on.
For example, for. Bash_profilein theEditerand the Termvariables have been modified,
withSourceExecute Script(called theEditerand the Termvariables), you do not have to log off or restart (PC).
Linux Command-source