linux - unix/linux shell 变量命名有什么规则吗?

标签 linux shell variables unix syntax

unix/linux shell 变量命名有什么规则吗?

比如像Java变量命名的通用规则。

最佳答案

您必须非常小心,不要将任何 UNIX 命令用作变量。它会弄乱代码并产生意想不到的结果。另外,请记住保留字(ifelseelifdodone...) 并且大写变量保留供系统使用。

来自Rules for Naming variable name :

Variable name must begin with alphanumeric alpha 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/

相关文章:

ios - 将变量从 iOS 传递到 watchOS

javascript - 函数标题变量

linux - 如何在 PulseAudio 中获取播放进程列表

linux - 如何重新连接到在 screen 中使用 ctrl-a x 停止的进程?

linux - 查找在过去 15 分钟内更改的文件,不包括一些子目录并将其压缩

linux - sed 提取给定日期之间的日志

c - 关于 pthread_rwlock_wrlock 和 pthread_rwlock_wrlock 的问题

linux - 如何创建 cygwin 可执行文件

bash - 在 shell 脚本中回显一些命令行(对单个命令回显)

java - 将 android 评级栏设置为从 float 变量最近的半星