unix/linux shell 变量命名有什么规则吗?
比如像Java变量命名的通用规则。
最佳答案
您必须非常小心,不要将任何 UNIX 命令用作变量。它会弄乱代码并产生意想不到的结果。另外,请记住保留字(if
、else
、elif
、do
、done
...) 并且大写变量保留供系统使用。
来自Rules for Naming variable name :
Variable name must begin with
alphanumericalpha character or underscore character (_), followed by one or more alphanumeric or underscore characters. Valid shell variable examples
或者如The Open Group Base Specifications Issue 7中所示:
In the shell command language, a word consisting solely of underscores, digits, and alphabetics from the portable character set. The first character of a name is not a digit.
关于linux - unix/linux shell 变量命名有什么规则吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15108065/