Variable name case

Note that in our example assignments earlier, variable names such as  myshell and today are in lowercase. Very often, when you read shell scripts others have written, particularly older scripts, you will find that variables that are used only internally in the script are written in uppercase, such as MYSHELL.

The issue with using the ALL_UPPERCASE variable names for your own script variables is that environment variables, such as HOME, and shell internal variables, such as BASH_VERSION, are also (almost) always written in uppercase, and there are a lot of them  so if you use capitalized names, there is a significant risk of accidentally breaking an important variable in your own script.

For example, if you were to assign PATH rather than path for one of your variables, you would change the environment variable that the system uses to find other programs:

#!/bin/sh
PATH=/home/bashuser/myfile
grep -- mystring "$PATH"

If this script is run, it yields:

grep: command not found

This is because with PATH changed to a filename, the system can no longer find the fundamental grep tool  and the error message doesn't make it clear why. Similar problems occur with names such as BASH_VERSION, SHELL, or even innocent-looking words such as RANDOM.

You can avoid this class of problems by naming variables for your script in all lowercase, since very few shell-internal and environment variables are written like this:

#!/bin/sh
path=/home/bashuser/myfille
grep -- mystring "$path"
There is one exception: the http_proxy environment variable used by some programs is always written lowercase, for historical reasons.

Of course, if you really do want to change one of these variables, you can still do so:

PATH="$PATH:/home/myuser/scripts"
MYDIR=/home/myuser
export MYDIR