加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash脚本中${VAR:= value}的结果是什么?

发布时间:2020-12-15 22:09:45 所属栏目:安全 来源:网络整理
导读:我正在查看几个使用:= $$}之间的bash脚本.例如,模式如下所示: export VAR=${VAR:=value} 这是做什么的? 如果VAR不存在,它是否为VAR分配值? 解决方法 按照 documentation: ${parameter:=word} If parameter is unset or null,the expansion of word is a
我正在查看几个使用:= $$}之间的bash脚本.例如,模式如下所示:

export VAR=${VAR:=value}

这是做什么的?
如果VAR不存在,它是否为VAR分配值?

解决方法

按照 documentation:

${parameter:=word}

If parameter is unset or null,the expansion of word is assigned to parameter. The value of parameter is then substituted. Positional parameters and special parameters may not be assigned to in this way.

因此,它使用其值导出VAR值,或者如果未设置/ null,则使用文字值导出.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读