Use of variables in the shell (2)

Source: Internet
Author: User

Some knowledge of variables in the shell:

Variable:

1. By default, all variables are considered to be stored as strings.

2. Variable case sensitivity

3. Add $ to the variable name before accessing the content

4. No declaration required

5. The $ extension is allowed in double quotes (replaced with the value of the variable), and the single quotation mark does not work.

Example:

S=hello # (Note that no spaces are allowed on both sides of the equals sign)

Echo $s

Environment variables:

When the shell script starts executing, some variables are initialized according to the values in the environment settings, which are environment variables. Get used to capital letters.

$HOME the home directory of the current user

$PATH a colon-separated list of directories to search for commands

The name of the shell script

$# the number of arguments passed to the script

$$ the process number of the shell script

3. Parametric variables

If the script is run with parameters, these parameter variables are created

$1,$2. Parameters of a script program

$* all the parameters to TFS to separate

[email protected] parameters are not squeezed together by $* variants

Use of variables in the shell (2)

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.