1.2-shell variable

Source: Internet
Author: User

The variables are divided into 2 types: 1 system Variable 2: User-defined variable

env Display system variable set display system variables and user-defined variables

Custom variable rule: a=1 = number cannot have spaces on either side

Can only consist of numbers, letters and underscores, and cannot start with a number (such as 2a=1)

and avoid using system commands or keywords (e.g., ls if done)

Single quotes (e.g. b= ' ls/etc ') are required when there are special symbols in a custom variable

No single quotes will be error, special symbols have/spaces * #, etc.

When stacking variables, it is best to use double quotes "" (e.g. b= "$a" 113)

Because of the shell's nature, it can exist many child processes, so custom variables are only valid in the current environment. If you need a child process to take effect, you need to declare the custom variable in the shell so that it takes effect globally.

Custom variable Global effective vim/etc/profile recommended to write under/etc/profile.d/

Delete Custom variable unset b then echo$b no result


1.2-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.