Linux Command-source

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.