Skip to content

Commit

Permalink
[+]变量替换
Browse files Browse the repository at this point in the history
  • Loading branch information
yanlele committed Jul 4, 2019
1 parent 8609790 commit bbe22eb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions book/15、Linux相关知识点/05、shell/01、基础篇/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,14 @@ echo "Date is $DATE"
```
#### 变量替换
形式 |说明
:- | :-
${var}| 变量本来的值
${var:-word}| 如果变量 var 为空或已被删除(unset),那么返回 word,但不改变 var 的值。
${var:=word}| 如果变量 var 为空或已被删除(unset),那么返回 word,并将 var 的值设置为 word。
${var:?message}| 如果变量 var 为空或已被删除(unset),那么将消息 message 送到标准错误输出,可以用来检测变量 var 是否可以被正常赋值。若此替换出现在Shell脚本中,那么脚本将停止运行。
${var:+word}| 如果变量 var 被定义,那么返回 word,但不改变 var 的值。

0 comments on commit bbe22eb

Please sign in to comment.