"Shell" variable

Source: Internet
Author: User

Variable settings:

~/dos # dfs=2  

Variable use:

You can read it using EHCO, but you need to precede the variable name with $, or the ${variable}.

~/dos # echo $dfs                                                               2       ~/dos # echo ${dfs}                                                             

Variable cancellation:

~/dos # unset DFS                                                               ~/dos # echo $dfs                                                               

Things to note:

1. Variables and variable contents with an equal sign "=" link, as shown: "Myname=vbird"

2. The equal sign cannot be directly connected to the space character, as shown in error: "myname = Vbird" Ring "Myname=vbird Tsai"

3. Variable names can only be English letters and numbers, but the beginning character cannot be a number, as shown in error: "2myname=vbird"

< Span style= "FONT-SIZE:12PT;" > 4. Variable contents If there is a space character can use the double quotation mark "" "or the single quotation mark" ' "to combine the variable content, but
o Span style= "font-family: ' Courier New '; font-size:10pt; " >o span>

< Span style= "FONT-SIZE:12PT;" > 5. Use the caret character "\" To turn special symbols (such as [Enter], $, \, space, ' etc.) into normal characters; span>

< Span style= "FONT-SIZE:12PT;" > 6. In a sequence of instructions, you also need to provide information by other instructions, using the inverted single quotation mark "' Instruction '" ring "$ (Instruction

< Span style= "FONT-SIZE:12PT;" > For example, to get core version setting: Span style= "FONT-SIZE:12PT;" > "version=$ (uname-r)" and "Echo $version" can have "2.6.18-128.el5"

< Span style= "FONT-SIZE:12PT;" > 7. If the variable is the content of the amplified variable, the contents can be summed with the "$ variable name" or the ${volume}, as follows:

8. If the variable needs to be executed in another subroutine , you need to export the variable to an environment variable:

9. The method for canceling the volume is to use unset: "unset-out name", for example, MyName

Exposing with EHCO to be able to read, just is required in the name of the volume of the first add $, the abstinence is ${hair volume} way 杢 canceled use can

"Shell" variable

Related Article

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.