Linux Shell variable configuration code

Source: Internet
Author: User

Variable configuration rules

    1. The variable and the variable content are linked with an equal sign "=", as shown below:
      "Myname = vbird 』

    2. The equal sign cannot be directly followed by a space character, as shown below:

      "Myname = vbird" or "myname = vbird Tsai 』

    3. The variable name can only contain English letters and numbers, but cannot start with a number. The following is an error:

      "2 myname = vbird 』

    4. If there is a space character in the variable content, you can use double quotation marks "or single quotation marks" '"to combine the variable content,
      • Special characters in double quotation marks, such as $, can retain the original features, as shown below:
        For "Var =" Lang is $ Lang "", "Echo $ Var" can obtain "Lang is en_us 』
      • Special characters in single quotes are only common characters (plain text), as shown below:
        For "Var = 'lang is $ Lang '", "Echo $ Var" can obtain "Lang is $ Lang 』
    5. The Escape Character "\" can be used to place special characters (such as [enter], $, \, space characters,
      ', Etc.) to a general character;

    6. You can use the 'command' or
      '$ (Command )』. Note that the one on the left of the number key 1 on the top of the keyboard is not a single quotation mark!
      For example, to obtain the configuration of the core version:
      "Version = $ (uname-R)" and then "Echo
      For $ version, see "2.6.18-128. EL5 』

    7. If the variable is an expanded variable, you can use "$ variable name" or "$ {Variable}" to accumulate the content, as shown below:
      "Path =" $ path ":/home/bin 』

    8. If the variable needs to be run in another subroutine, you need to use export to convert the variable into an environment variable:
      "Export path 』

    9. Generally, upper-case characters are default variables of the system. You can use lower-case characters to configure variables for easy judgment (purely based on user interests and hobbies );
    10. To cancel a variable, use unset: "Unset
      For example, cancel the configuration of myname:
      "Unset myname 』

 

[Transfer] http://vbird.dic.ksu.edu.tw/linux_basic/0320bash_2.php

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.