1.2 Shell variables

Source: Internet
Author: User

#系统变量

Env View System Variables

echo $HOSTNAME View variable contents

Set view system environment variables, also display user-defined variables, compare all


#用户自定义变量

a=1;b=2 Defining variables

echo $a $b output variable value


#引用变量执行结果

Myvim= ' which vim '


#变量与数字相结合要加双引号

D= "$myvim" 3

#进入子shell, the previously defined variable does not exist

Bash


#要使用之前定义的变量, to declare globally

Export A=1

Bash

The variables defined before the Echo $a can also be used


#取消变量值

Unset D

Echo $d


Exercises

1. What are the rules that a variable name needs to conform to when customizing variables?

Variable names can contain uppercase letters

Variable names can only contain numbers, letters, and underscores

2. Which command can I use to display the variables you just defined?

Set

3. What do I need to do if I want to use a custom variable in a child shell?

Export A=1


Summarize:

Main: Global declaration variable export cancel variable value unset


1.2 Shell variables

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.