Linux under Variable configuration rules

Source: Internet
Author: User

Tips:
In the example below, the Var and str are variables and we want to determine the value of Var against whether Str has a configuration. In general, str: for "STR is not configured or empty string", and Str is only "no this variable".

How variables are configured STR Not Configured Str is an empty string STR is configured not to be an empty string
VAR=${STR-EXPR} var=expr Var= Var= $str
VAR=${STR:-EXPR} var=expr var=expr Var= $str
VAR=${STR+EXPR} Var= var=expr var=expr
VAR=${STR:+EXPR} Var= Var= var=expr
VAR=${STR=EXPR} str=expr
var=expr
STR does not change
Var=
STR does not change
Var= $str
VAR=${STR:=EXPR} str=expr
var=expr
str=expr
var=expr
STR does not change
Var= $str
VAR=${STR?EXPR} Expr output to stderr Var= Var= $str
VAR=${STR:?EXPR} Expr output to stderr Expr output to stderr Var= $str

Linux under Variable configuration rules

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.