用法
| Parameter | What does it do? |
|---|---|
${VAR:-STRING} |
If VAR is empty or unset, use STRING as its value. |
${VAR-STRING} |
If VAR is unset, use STRING as its value. |
${VAR:=STRING} |
If VAR is empty or unset, set the value of VAR to STRING. |
${VAR=STRING} |
If VAR is unset, set the value of VAR to STRING. |
${VAR:+STRING} |
If VAR is not empty, use STRING as its value. |
${VAR+STRING} |
If VAR is set, use STRING as its value. |
${VAR:?STRING} |
Display an error if empty or unset. |
${VAR?STRING} |
Display an error if unset. |
例子
执行下面的例子,如果环境变量中CONF的值存在,则取CONF的值,否则用默认值7
#/bin/basha=${CONF:-"7"}echo $a;
