Linux execution script specification and execution commands

Source: Internet
Author: User

1. Specify the script interpreter at the beginning

#!/bin/bash or #!/bin/sh

2, and then add version information, etc.

#Date: 2016-12-27

#Author: sadoc.blog.51cto.com

#Mail: [Email protected]

#Function: Scripting Features

#Version: Version

The script is named after the. sh extension

"source" and " . "Load the executed script, the variable (including function) value in the script after the end of the script still exists in the current shell,"sh" and" bash "is not


Global variables:/etc/profile variables under this directory all users are in effect

Current User variables:. bash_profile variables are only valid in the current user mode

Export variables with export

Modifying a Set Variable environment requires "." The "source" load takes effect

For example: Vim /etc/profile or . Bash_profile added

Export A=nihao


The difference between a single quote, a double quote, and a non-quoted variable:

Single quotes:

That is, the single quote content is output as is, or what you see in single quotation marks.

Double quotes:

If there are commands and variables inside the double quotes, the variables and commands are parsed out and then the final content is output.

No quotation marks:

Output of the content, the string containing the space will be treated as a whole output, if there is a command or variable, will be the command variable parsing output, if the string with a holding and other special characters, it is not fully output, need to use double quotation marks.

Linux execution script specification and execution commands

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.