Usage of source in Linux

Source: Internet
Author: User

Tag: Log off Log ash command specifies the link. COM Read environment variable

SOURCE command:
function of the source command: causes the shell to read into the specified shell program file and executes all the statements in the file sequentially
The source command is typically used to re-execute the initialization file you just modified to take effect immediately without having to log off and log back on.
Usage:
SOURCE filename or. FileName
The source command (from Shell C) is the built-in command of the bash shell, and the Point Command (.), which is a dot symbol (from the Bourne Shell), is another name for source.

What is the difference between the source filename and the sh filename and./filename execution script?

  • When the shell script has executable permissions, there is no difference between using the SH filename and the./filename execution script.
  • SH filename re-establishes a child shell, executes the statement inside the script in the child shell, which inherits the environment variables of the parent shell, but the new, changed variables of the child shell are not brought back to the parent shell unless export is used.
  • SOURCE filename: This command actually simply reads the statements inside the script and executes them sequentially in the current shell, without creating a new child shell. Then all the new and changed statements in the script will be stored in the current shell.

Reference Link: The source command under Linux

Usage of source in Linux

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.