Linux Command, linuxcommand

Source: Internet
Author: User

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 ).


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.