Significance of using source or "." To execute shell scripts

Source: Internet
Author: User

If you use source or "." To execute a shell script (such as son. Sh), all statements in the script will be run as part of the current parent shell process. If son. sh execution statement source son. sh or. son. SH is a parent shell script (father. SH), then son. the values of the variables in the sh script or the return values of the functions will be passed to the parent shell script father. sh.

Therefore, use source or ". the biggest difference between using the shell script and using the sh command is that the former loads and executes each line of commands in the script in the current shell, instead of generating a sub-shell to execute these commands.

A typical application is to modify the. bashrc,. bash_profile, and other environment information configuration files in the home directory. You need to execute these files as follows to make the changes take effect:

$ Source. bashrc $ .. bash_profile


Significance of using source or "." To execute shell scripts

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.