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

shell脚本中${variable_name}和$variable_name之间的区别是什么

发布时间:2020-12-15 21:30:29 所属栏目:安全 来源:网络整理
导读:在 Shell脚本中,它们是声明变量,如${variable_name},它是否等于$variable_name ${variable_name}和$variable_name之间有什么区别? 解决方法 The curly brace form is less ambiguous because if the braces are omitted the shell may not be able to disti
在 Shell脚本中,它们是声明变量,如${variable_name},它是否等于$variable_name
${variable_name}和$variable_name之间有什么区别?

解决方法

The curly brace form is less ambiguous
because if the braces are omitted the
shell may not be able to distinguish
between a variable name and the text
surrounding it.

如果你用这样的文本写了一个变量($myvariable)

echo foo$myvariablebar

然后shell可能无法区分变量名,因此您需要像这样使用{}

echo foo${myvariable}bar

然后shell知道myvariable是一个变量,bar是文本

结帐here是一个明确的解释.

(编辑:李大同)

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

    推荐文章
      热点阅读