linux host=${host:-"localhost"}使用方法

时间:2014-12-10 12:25:48   收藏:0   阅读:161

localhost=${host:-"localhost"}

host 变量未设定或者为空,host取"-"后面的值;否则host=$host

host=${host-"localhost"}

host 变量未设定,host取"-"后面的值;否则如果变量host为空或者有值host=$host

 

host=${host:-"localhost"}

一般前面会有一个read -p "请输入一个参数:" host

即:当提示你输入参数,但是你直接Enter,这时候host是为空的, localhost这个字符串作为它的值.否则就会使用你输入的字符串作为值

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!