Linux Command, linuxcommand
We know that source executes scripts. What is the difference between source and normal execution?
Test1.sh
#!/bin/shexport KKK=111
Normal execution:
tdtc010@tdtc010-Vostro-270:~$ ./test1.shtdtc010@tdtc010-Vostro-270:~$ echo $KKK
No results.
Source execution:
tdtc010@tdtc010-Vostro-270:~$ source test1.shtdtc010@tdtc010-Vostro-270:~$ echo $KKK111
There are results.
Why?
Because./test1.sh is run in the sub-shell and is not reflected in the parent shell, the result is not displayed.
However, source is executed in this shell, so you can see the result.
Because of its "Explicit" feature, source (or dot command) is usually used to re-execute the modified initialization document,
For example,. bash_profile and. profile.
For example, the EDITER and TERM variables in. bash_profile are modified,
When you use source to execute the script (EDITER and TERM variables are called), you do not need to log out or restart (PC ).