标签:color span padding img bsp strong 技术分享 输出 default
格式 | var1为空 | var1不为空 |
var2=${var1:-string} |
var2=string var1不变 |
var2=$var1 var1不变 |
var2=${var1:=string} |
var2=string var1=string |
var2=$var1 var1不变 |
var2=${var1:+string} |
var2为空 var1不变(也就是说var1也是空) |
var2=string var1不变 |
var2=${var1:?string} |
输出格式: shell脚本名:var1=string 并退出shell var2不变 |
var2=$var1 var1不变 |
1.var2=${var1:-string}
echo -n "input var1:" read var1 var2=${var1:-"this is default value"} echo "var2=$var2" echo "var1=$var1"
2.var2=${var1:=string}
echo -n "input var1:" read var1 var2=${var1:="this is default value"} echo "var2=$var2" echo "var1=$var1"
3.var2=${var1:+string}
echo -n "input var1:" read var1 var2=${var1:+"this is default value"} echo "var2=$var2" echo "var1=$var1"
4.var2=${var1:?string}
echo -n "input var1:" read var1 var2=${var1:?"this is default value"} echo "var2=$var2" echo "var1=$var1"
标签:color span padding img bsp strong 技术分享 输出 default
原文地址:http://www.cnblogs.com/wwzyy/p/6103938.html