Most languages have naming conventions for variables, the most common style I see in shell scripts is MY_VARIABLE=foo
. Is this the convention or is it only for global variables? What about variables local to the script?
Shell Scripts – Naming Conventions for Variables
bashshellshell-scriptvariable
Best Answer
Environment variables or shell variables that are introduced by the operating system, shell startup scripts, or by the shell itself etc. are usually all in
CAPITALS
.To prevent your own variables from conflicting with these variables, it is a good practice to use
lower_case
variable names.