Shell two classes of execution methods

Source: Internet
Author: User

such as script scripts.sh

1. Create a new shell

Add statement at the beginning of the scripts file: #!/bin/sh, via ./scripts.sh(requires execute permission) or sh scripts.sh(no execute permission required)

2. Do not create a new shell, execute commands under the current shell

Pass. (dot)./scripts.sh or source./scripts.sh execution

Extended function point:

Source and Point commands

The source command is a built-in command of the Bash shell, which comes from C shell.

Another notation for the source command is the point symbol, which is used in the same way as source, from the Bourne shell.

The source command can force a script to immediately affect the current environment.

The source command enforces all commands in the script and ignores the permissions of the file.

The source command is typically used to re-execute a newly modified initialization file, such as. Bash_profile and. Profile, and so on.

The source command can affect the environment of the parent Shell that executes the script, and export can only affect the environment of its child Shell .

Shell two classes of execution methods

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.