[英]How to use `-` in the name of a Bash variable?
I stored a variable named jenkins-vm="Jenkins"
while calling the variable using echo $jenkins-vm
I am facing error.我在使用
echo $jenkins-vm
调用变量时存储了一个名为jenkins-vm="Jenkins"
的变量,但我遇到了错误。 How can I escape "-" while using it in a variable?在变量中使用“-”时如何转义?
The hyphen or dash character -
is not allowed in a variable name in the Bash shell. Bash shell 中的变量名称
-
不允许使用连字符或短划线字符。 Only lowercase/uppercase ASCII letters, _
(underline), and digits are supported, and the first character must not be a digit.仅支持小写/大写 ASCII 字母、
_
(下划线)和数字,并且第一个字符不能是数字。 Replacing the hyphen(s) in the variable name with underline characters will work, and the variable name will still be easy to read.将变量名称中的连字符替换为下划线字符将起作用,并且变量名称仍然易于阅读。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.